Initial Commit

This commit is contained in:
Anders Böttcher
2026-05-11 23:39:16 +02:00
parent 9dde8d8804
commit 50566f2a22
38 changed files with 5840 additions and 1015 deletions
@@ -0,0 +1,39 @@
import { NextResponse } from 'next/server'
import { getFile, getUploadPath } from '@/lib/store'
import fs from 'fs'
export async function GET(
_request: Request,
{ params }: { params: Promise<{ token: string }> },
) {
const { token } = await params
const record = await getFile(token)
if (!record) {
return NextResponse.json({ error: 'Not found' }, { status: 404 })
}
const filePath = getUploadPath(token, record.originalName)
if (!fs.existsSync(filePath)) {
return NextResponse.json({ error: 'File missing on disk' }, { status: 404 })
}
const stream = fs.createReadStream(filePath)
const webStream = new ReadableStream({
start(controller) {
stream.on('data', (chunk) => controller.enqueue(chunk))
stream.on('end', () => controller.close())
stream.on('error', (err) => controller.error(err))
},
cancel() {
stream.destroy()
},
})
return new Response(webStream, {
headers: {
'Content-Type': 'application/octet-stream',
'Content-Disposition': `attachment; filename="${record.originalName}"`,
'Content-Length': String(record.size),
},
})
}
+14
View File
@@ -0,0 +1,14 @@
import { NextResponse } from 'next/server'
import { getFile } from '@/lib/store'
export async function GET(
_request: Request,
{ params }: { params: Promise<{ token: string }> },
) {
const { token } = await params
const record = await getFile(token)
if (!record) {
return NextResponse.json({ error: 'Not found' }, { status: 404 })
}
return NextResponse.json(record)
}
+7
View File
@@ -0,0 +1,7 @@
import { NextResponse } from 'next/server'
import { readMeta } from '@/lib/store'
export async function GET() {
const records = await readMeta()
return NextResponse.json(records)
}
+70
View File
@@ -0,0 +1,70 @@
import { NextResponse } from 'next/server'
import { nanoid } from 'nanoid'
import { addFile } from '@/lib/store'
import type { FileRecord } from '@/lib/store'
const ALLOWED_EXTENSIONS = ['.backerup', '.json']
const MAX_SIZE_BYTES = 500 * 1024 * 1024 // 500 MB
export async function POST(request: Request) {
let formData: FormData
try {
formData = await request.formData()
} catch {
return NextResponse.json({ error: 'Invalid form data' }, { status: 400 })
}
const file = formData.get('file')
if (!(file instanceof File)) {
return NextResponse.json({ error: 'No file provided' }, { status: 400 })
}
const nameLower = file.name.toLowerCase()
if (!ALLOWED_EXTENSIONS.some((ext) => nameLower.endsWith(ext))) {
return NextResponse.json(
{ error: 'Only .backerup and .json files are accepted' },
{ status: 400 },
)
}
const buffer = Buffer.from(await file.arrayBuffer())
if (buffer.byteLength > MAX_SIZE_BYTES) {
return NextResponse.json({ error: 'File exceeds 500 MB limit' }, { status: 413 })
}
const type: FileRecord['type'] = nameLower.endsWith('.backerup') ? 'backerup' : 'config'
const description = String(formData.get('description') ?? '').trim() || undefined
const displayName = String(formData.get('displayName') ?? '').trim() || undefined
const group = String(formData.get('group') ?? '').trim() || undefined
let containerName: string | undefined
let image: string | undefined
if (type === 'config') {
try {
const raw = JSON.parse(buffer.toString('utf-8')) as Record<string, unknown>
const name = String((raw.Name as string | undefined) ?? '').replace(/^\//, '')
containerName = name || undefined
const cfg = raw.Config as Record<string, unknown> | undefined
image = (cfg?.Image as string | undefined) || undefined
} catch {
// Not valid JSON — still accept the file
}
}
const token = nanoid(10)
const record: FileRecord = {
token,
originalName: file.name,
displayName,
size: buffer.byteLength,
type,
uploadedAt: new Date().toISOString(),
description,
group,
containerName,
image,
}
await addFile(record, buffer)
return NextResponse.json({ token })
}
+47
View File
@@ -0,0 +1,47 @@
"use client";
import { useRouter } from "next/navigation";
export default function BrowseClient({
groups,
selectedGroup,
}: {
groups: string[];
selectedGroup: string | null;
}) {
const router = useRouter();
function select(g: string | null) {
if (g === null) {
router.push("/browse");
} else {
router.push(`/browse?group=${encodeURIComponent(g)}`);
}
}
return (
<div className="mb-8 flex flex-wrap gap-2">
<button
onClick={() => select(null)}
className={`rounded-full px-4 py-1.5 text-xs font-semibold transition-colors ${selectedGroup === null
? "bg-cyan-500 text-slate-900"
: "border border-slate-700 bg-slate-800/50 text-slate-400 hover:border-slate-500 hover:text-slate-200"
}`}
>
All
</button>
{groups.map((g) => (
<button
key={g}
onClick={() => select(g)}
className={`rounded-full px-4 py-1.5 text-xs font-semibold transition-colors ${selectedGroup === g
? "bg-cyan-500 text-slate-900"
: "border border-slate-700 bg-slate-800/50 text-slate-400 hover:border-slate-500 hover:text-slate-200"
}`}
>
{g}
</button>
))}
</div>
);
}
+112
View File
@@ -0,0 +1,112 @@
import Link from "next/link";
import { readMeta, listGroups } from "@/lib/store";
import type { FileRecord } from "@/lib/store";
import BrowseClient from "./BrowseClient";
function formatBytes(n: number) {
if (n < 1024) return `${n} B`;
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
return `${(n / 1024 / 1024).toFixed(2)} MB`;
}
function TypeBadge({ type }: { type: FileRecord["type"] }) {
return type === "backerup" ? (
<span className="rounded-full bg-cyan-500/15 px-2.5 py-0.5 text-[11px] font-semibold text-cyan-400">
.backerup
</span>
) : (
<span className="rounded-full bg-violet-500/15 px-2.5 py-0.5 text-[11px] font-semibold text-violet-400">
.json config
</span>
);
}
export default async function BrowsePage({
searchParams,
}: {
searchParams: Promise<{ group?: string }>;
}) {
const { group: selectedGroup } = await searchParams;
const [allRecords, groups] = await Promise.all([readMeta(), listGroups()]);
const records = selectedGroup
? allRecords.filter((r) => r.group === selectedGroup)
: allRecords;
return (
<div className="mx-auto max-w-5xl px-6 py-16">
<div className="mb-10 flex flex-wrap items-end justify-between gap-4">
<div>
<h1 className="text-3xl font-bold text-white">Browse shared files</h1>
<p className="mt-2 text-slate-400">
{records.length} file{records.length !== 1 ? "s" : ""}
{selectedGroup ? ` in "${selectedGroup}"` : " shared by the community"}.
</p>
</div>
<Link
href="/share"
className="rounded-xl bg-cyan-500 px-6 py-2.5 text-sm font-bold text-slate-900 hover:bg-cyan-400 transition-colors"
>
+ Share a file
</Link>
</div>
{/* Group filter bar */}
{groups.length > 0 && (
<BrowseClient groups={groups} selectedGroup={selectedGroup ?? null} />
)}
{records.length === 0 ? (
<div className="rounded-2xl border border-slate-800 bg-slate-900/60 p-16 text-center">
<p className="text-4xl">📭</p>
<p className="mt-4 text-slate-400">
{selectedGroup ? `No files in group "${selectedGroup}".` : "No files shared yet."}
</p>
<Link href="/share" className="mt-4 inline-block text-sm text-cyan-400 hover:underline">
Be the first to share one
</Link>
</div>
) : (
<div className="grid gap-4 sm:grid-cols-2">
{records.map((r) => (
<Link
key={r.token}
href={`/files/${r.token}`}
className="group rounded-2xl border border-slate-800 bg-slate-900/60 p-5 transition hover:border-slate-600 hover:bg-slate-900"
>
<div className="flex items-start justify-between gap-3">
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2 flex-wrap">
<TypeBadge type={r.type} />
{r.group && (
<span className="rounded-full bg-slate-700/60 px-2.5 py-0.5 text-[11px] font-medium text-slate-400">
{r.group}
</span>
)}
<span className="truncate font-mono text-xs text-slate-500">{r.originalName}</span>
</div>
{(r.displayName ?? r.containerName) && (
<p className="mt-2 font-semibold text-white truncate">
{r.displayName ?? r.containerName}
</p>
)}
{r.image && (
<p className="mt-0.5 text-xs text-slate-400 truncate">{r.image}</p>
)}
{r.description && (
<p className="mt-2 text-sm text-slate-400 line-clamp-2">{r.description}</p>
)}
</div>
<span className="shrink-0 text-slate-600 group-hover:text-slate-400 transition-colors text-lg"></span>
</div>
<div className="mt-4 flex items-center gap-4 text-xs text-slate-600">
<span>{formatBytes(r.size)}</span>
<span>{new Date(r.uploadedAt).toLocaleDateString()}</span>
</div>
</Link>
))}
</div>
)}
</div>
);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

@@ -0,0 +1,18 @@
"use client";
export default function CopyLinkButton({ token }: { token: string }) {
function copy() {
const url = `${window.location.origin}/files/${token}`;
navigator.clipboard.writeText(url).then(() => {
alert("Link copied to clipboard!");
});
}
return (
<button
onClick={copy}
className="flex w-full items-center justify-center gap-2 rounded-xl border border-slate-700 py-3 text-sm font-semibold text-slate-300 hover:bg-slate-800 hover:text-white transition-colors"
>
Copy share link
</button>
);
}
+14
View File
@@ -0,0 +1,14 @@
import Link from "next/link";
export default function NotFound() {
return (
<div className="flex min-h-[60vh] flex-col items-center justify-center px-6 text-center">
<p className="text-6xl">404</p>
<h1 className="mt-4 text-2xl font-bold text-white">File not found</h1>
<p className="mt-2 text-slate-400">This share link may have expired or never existed.</p>
<Link href="/browse" className="mt-6 text-sm text-cyan-400 hover:underline">
Browse all shared files
</Link>
</div>
);
}
+121
View File
@@ -0,0 +1,121 @@
import Link from "next/link";
import { getFile } from "@/lib/store";
import { notFound } from "next/navigation";
import CopyLinkButton from "./CopyLinkButton";
function formatBytes(n: number) {
if (n < 1024) return `${n} B`;
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
return `${(n / 1024 / 1024).toFixed(2)} MB`;
}
export default async function FileDetailPage({
params,
}: {
params: Promise<{ token: string }>;
}) {
const { token } = await params;
const record = await getFile(token);
if (!record) notFound();
const isBackerup = record.type === "backerup";
const downloadUrl = `/api/files/${token}/download`;
return (
<div className="mx-auto max-w-2xl px-6 py-16">
<Link href="/browse" className="text-xs text-slate-500 hover:text-slate-300 transition-colors">
Back to browse
</Link>
<div className="mt-6">
<div className="flex items-center gap-3 flex-wrap">
{isBackerup ? (
<span className="rounded-full bg-cyan-500/15 px-3 py-1 text-xs font-semibold text-cyan-400">
.backerup
</span>
) : (
<span className="rounded-full bg-violet-500/15 px-3 py-1 text-xs font-semibold text-violet-400">
.json config
</span>
)}
<span className="font-mono text-sm text-slate-500">{record.originalName}</span>
</div>
{record.group && (
<span className="mt-3 inline-block rounded-full bg-slate-700/60 px-3 py-0.5 text-xs font-medium text-slate-400">
{record.group}
</span>
)}
<h1 className="mt-4 text-3xl font-bold text-white">
{record.displayName ?? record.containerName ?? record.originalName}
</h1>
{record.image && (
<p className="mt-1 text-slate-400">{record.image}</p>
)}
{record.description && (
<p className="mt-4 text-sm leading-relaxed text-slate-300">{record.description}</p>
)}
</div>
{/* Metadata grid */}
<div className="mt-8 rounded-2xl border border-slate-800 bg-slate-900/60 p-6 space-y-3">
<div className="flex items-center justify-between">
<span className="text-xs text-slate-500">File size</span>
<span className="text-sm font-mono text-slate-300">{formatBytes(record.size)}</span>
</div>
<div className="flex items-center justify-between">
<span className="text-xs text-slate-500">Uploaded</span>
<span className="text-sm text-slate-300">
{new Date(record.uploadedAt).toLocaleString()}
</span>
</div>
{record.group && (
<div className="flex items-center justify-between">
<span className="text-xs text-slate-500">Group</span>
<span className="text-sm font-mono text-slate-300">{record.group}</span>
</div>
)}
{record.containerName && (
<div className="flex items-center justify-between">
<span className="text-xs text-slate-500">Container name</span>
<span className="text-sm font-mono text-slate-300">{record.containerName}</span>
</div>
)}
{record.image && (
<div className="flex items-center justify-between">
<span className="text-xs text-slate-500">Image</span>
<span className="text-sm font-mono text-slate-300">{record.image}</span>
</div>
)}
<div className="flex items-center justify-between">
<span className="text-xs text-slate-500">Share token</span>
<span className="text-sm font-mono text-slate-400">{token}</span>
</div>
</div>
{/* Actions */}
<div className="mt-6 space-y-3">
<a
href={downloadUrl}
className="flex w-full items-center justify-center gap-2 rounded-xl bg-cyan-500 py-3 text-sm font-bold text-slate-900 hover:bg-cyan-400 transition-colors"
download={record.originalName}
>
Download {record.originalName}
</a>
{/* Copy link */}
<CopyLinkButton token={token} />
</div>
{isBackerup && (
<div className="mt-8 rounded-xl border border-amber-500/20 bg-amber-500/5 p-4 text-xs text-amber-300">
<strong>Note:</strong> This is a full .backerup archive. It may contain volume data
in addition to the container config. Import it into Backerup to restore
or clone the container.
</div>
)}
</div>
);
}
+19
View File
@@ -0,0 +1,19 @@
@import "tailwindcss";
:root {
--background: #0b0f1a;
--foreground: #e2e8f0;
}
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono);
}
body {
background: var(--background);
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
}
+73
View File
@@ -0,0 +1,73 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import Link from "next/link";
import "./globals.css";
const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});
const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});
export const metadata: Metadata = {
title: "Backerup — Docker Container Backup",
description:
"Simple, reliable Docker container backups. Share and discover container configs and backup snapshots.",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html
lang="en"
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
>
<body className="min-h-full flex flex-col bg-[#0b0f1a] text-slate-200">
{/* Nav */}
<header className="sticky top-0 z-50 border-b border-slate-800 bg-[#0b0f1a]/90 backdrop-blur">
<div className="mx-auto flex max-w-6xl items-center justify-between px-6 py-4">
<Link href="/" className="flex items-center gap-2 font-bold text-lg text-white">
<span className="rounded bg-cyan-500 px-1.5 py-0.5 text-xs font-mono text-slate-900">
.backerup
</span>
<span>Backerup</span>
</Link>
<nav className="flex items-center gap-6 text-sm text-slate-400">
<Link href="/browse" className="hover:text-white transition-colors">Browse</Link>
<Link href="/share" className="hover:text-white transition-colors">Share</Link>
<Link
href="/share"
className="rounded-lg bg-cyan-500 px-4 py-1.5 text-sm font-semibold text-slate-900 hover:bg-cyan-400 transition-colors"
>
Upload
</Link>
</nav>
</div>
</header>
{/* Page content */}
<main className="flex-1">{children}</main>
{/* Footer */}
<footer className="border-t border-slate-800 py-8 text-center text-xs text-slate-600">
<p>
Backerup &mdash; open-source Docker backup.{" "}
<a
href="https://github.com"
className="text-slate-500 hover:text-slate-300 transition-colors"
>
GitHub
</a>
</p>
</footer>
</body>
</html>
);
}
+170
View File
@@ -0,0 +1,170 @@
import Link from "next/link";
const features = [
{
icon: "📦",
title: "Full container backups",
body: "Archive volumes, bind mounts, and Docker inspect metadata into a single .backerup bundle — everything needed to fully restore or clone a container.",
},
{
icon: "🗂",
title: "Config-only export",
body: "Export a lightweight .config.json (raw docker inspect output) to recreate a container on any host without moving volume data.",
},
{
icon: "🔄",
title: "One-click restore",
body: "Restore a container's volumes and config in-place, rebuild its config without touching data, or spin up a brand-new container from any backup.",
},
{
icon: "📅",
title: "Scheduled backups",
body: "Define cron-based backup jobs per container with configurable retention strategies: keep latest N, keep every N-th, or purge older than N days.",
},
{
icon: "🌐",
title: "Community sharing",
body: "Publish your container configs so others can spin up the same setup in seconds. Browse configs shared by the community right here.",
},
{
icon: "🔒",
title: "Self-hosted & private",
body: "Runs entirely inside your Docker environment. No cloud dependencies, no data leaves your server unless you choose to share.",
},
];
const steps = [
{ n: "1", title: "Install", body: "Run Backerup as a Docker container with access to your Docker socket." },
{ n: "2", title: "Configure", body: "Add containers, choose a backup strategy, and set a cron schedule." },
{ n: "3", title: "Backup", body: "Backerup archives your volumes and metadata into a portable .backerup file." },
{ n: "4", title: "Restore", body: "One click to restore in-place, rebuild config, or create a new container." },
];
export default function LandingPage() {
return (
<>
{/* Hero */}
<section className="relative overflow-hidden px-6 py-28 text-center">
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
<div className="h-[500px] w-[900px] rounded-full bg-cyan-500/10 blur-3xl" />
</div>
<div className="relative mx-auto max-w-3xl">
<span className="inline-block rounded-full border border-cyan-500/30 bg-cyan-500/10 px-4 py-1 text-xs font-semibold uppercase tracking-widest text-cyan-400">
Open Source · Self-Hosted
</span>
<h1 className="mt-6 text-5xl font-bold leading-tight tracking-tight text-white sm:text-6xl">
Docker backups,{" "}
<span className="text-cyan-400">done right.</span>
</h1>
<p className="mt-6 text-lg text-slate-400">
Backerup bundles your container volumes, bind mounts, and config into
a single portable file. Restore in seconds, share configs with your
team, or migrate containers between hosts.
</p>
<div className="mt-10 flex flex-wrap justify-center gap-4">
<Link
href="/share"
className="rounded-xl bg-cyan-500 px-8 py-3 text-sm font-bold text-slate-900 hover:bg-cyan-400 transition-colors"
>
Share a config
</Link>
<Link
href="/browse"
className="rounded-xl border border-slate-700 bg-slate-800/50 px-8 py-3 text-sm font-semibold text-slate-200 hover:bg-slate-700 transition-colors"
>
Browse configs
</Link>
</div>
</div>
{/* Terminal preview */}
<div className="relative mx-auto mt-16 max-w-2xl rounded-2xl border border-slate-700 bg-slate-900 text-left shadow-2xl">
<div className="flex items-center gap-2 border-b border-slate-700 px-4 py-3">
<span className="h-3 w-3 rounded-full bg-red-500/70" />
<span className="h-3 w-3 rounded-full bg-yellow-500/70" />
<span className="h-3 w-3 rounded-full bg-green-500/70" />
<span className="ml-4 text-xs text-slate-500 font-mono">backerup api</span>
</div>
<pre className="overflow-x-auto p-6 text-xs leading-6 font-mono text-slate-300">
{`
# Download the App
docker pull ghcr.io/evan-buss/backerup:latest
`}
</pre>
</div>
</section>
{/* Features */}
<section className="px-6 py-20">
<div className="mx-auto max-w-6xl">
<h2 className="text-center text-3xl font-bold text-white">Everything you need</h2>
<p className="mt-3 text-center text-slate-400">
A complete backup lifecycle all from a single self-hosted UI.
</p>
<div className="mt-14 grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
{features.map((f) => (
<div
key={f.title}
className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6 transition hover:border-slate-700"
>
<div className="text-3xl">{f.icon}</div>
<h3 className="mt-4 font-semibold text-white">{f.title}</h3>
<p className="mt-2 text-sm leading-relaxed text-slate-400">{f.body}</p>
</div>
))}
</div>
</div>
</section>
{/* How it works */}
<section className="bg-slate-900/40 px-6 py-20">
<div className="mx-auto max-w-4xl">
<h2 className="text-center text-3xl font-bold text-white">How it works</h2>
<div className="mt-14 grid gap-8 sm:grid-cols-2 lg:grid-cols-4">
{steps.map((s) => (
<div key={s.n} className="flex flex-col items-start gap-3">
<span className="flex h-10 w-10 items-center justify-center rounded-full bg-cyan-500/15 text-lg font-bold text-cyan-400">
{s.n}
</span>
<h3 className="font-semibold text-white">{s.title}</h3>
<p className="text-sm text-slate-400">{s.body}</p>
</div>
))}
</div>
</div>
</section>
{/* Format callout */}
<section className="px-6 py-20">
<div className="mx-auto max-w-4xl">
<div className="rounded-2xl border border-cyan-500/20 bg-cyan-500/5 p-10 text-center">
<h2 className="text-2xl font-bold text-white">
The <span className="font-mono text-cyan-400">.backerup</span> format
</h2>
<p className="mt-4 text-slate-400 max-w-xl mx-auto">
A single gzipped-tar file containing{" "}
<span className="font-mono text-slate-300">config.json</span>,{" "}
<span className="font-mono text-slate-300">manifest.json</span>, and{" "}
<span className="font-mono text-slate-300">volumes/*.tar.gz</span>.
Portable, transparent, and restorable without Backerup itself.
</p>
<div className="mt-8 flex flex-wrap justify-center gap-4">
<Link
href="/share"
className="rounded-xl bg-cyan-500 px-8 py-3 text-sm font-bold text-slate-900 hover:bg-cyan-400 transition-colors"
>
Upload a backup or config
</Link>
<Link
href="/browse"
className="rounded-xl border border-slate-700 px-8 py-3 text-sm font-semibold text-slate-300 hover:text-white hover:border-slate-500 transition-colors"
>
Browse shared files
</Link>
</div>
</div>
</div>
</section>
</>
);
}
+229
View File
@@ -0,0 +1,229 @@
"use client";
import { useEffect, useRef, useState } from "react";
import { useRouter } from "next/navigation";
const ACCEPTED = [".backerup", ".json"];
const MAX_BYTES = 500 * 1024 * 1024;
function formatBytes(n: number) {
if (n < 1024) return `${n} B`;
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
return `${(n / 1024 / 1024).toFixed(2)} MB`;
}
export default function SharePage() {
const router = useRouter();
const inputRef = useRef<HTMLInputElement>(null);
const [file, setFile] = useState<File | null>(null);
const [displayName, setDisplayName] = useState("");
const [description, setDescription] = useState("");
const [group, setGroup] = useState("");
const [existingGroups, setExistingGroups] = useState<string[]>([]);
const [dragging, setDragging] = useState(false);
const [uploading, setUploading] = useState(false);
const [error, setError] = useState<string | null>(null);
// Pre-fetch existing group names for autocomplete
useEffect(() => {
fetch("/api/files")
.then((r) => r.json())
.then((records: Array<{ group?: string }>) => {
const groups = Array.from(
new Set(records.map((r) => r.group).filter(Boolean) as string[])
).sort();
setExistingGroups(groups);
})
.catch(() => { });
}, []);
function pickFile(f: File) {
const name = f.name.toLowerCase();
if (!ACCEPTED.some((ext) => name.endsWith(ext))) {
setError("Only .backerup and .json files are accepted.");
return;
}
if (f.size > MAX_BYTES) {
setError("File exceeds the 500 MB limit.");
return;
}
setError(null);
setFile(f);
}
function onDrop(e: React.DragEvent) {
e.preventDefault();
setDragging(false);
const dropped = e.dataTransfer.files[0];
if (dropped) pickFile(dropped);
}
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
if (!file) return;
setUploading(true);
setError(null);
try {
const formData = new FormData();
formData.append("file", file);
if (displayName.trim()) formData.append("displayName", displayName.trim());
formData.append("description", description);
if (group.trim()) formData.append("group", group.trim());
const res = await fetch("/api/upload", { method: "POST", body: formData });
const data = (await res.json()) as { token?: string; error?: string };
if (!res.ok || !data.token) {
throw new Error(data.error ?? "Upload failed");
}
router.push(`/files/${data.token}`);
} catch (err) {
setError(err instanceof Error ? err.message : "Unknown error");
setUploading(false);
}
}
const isBackerup = file?.name.toLowerCase().endsWith(".backerup");
return (
<div className="mx-auto max-w-2xl px-6 py-16">
<div className="mb-10">
<h1 className="text-3xl font-bold text-white">Share a file</h1>
<p className="mt-2 text-slate-400">
Upload a{" "}
<span className="font-mono text-slate-300">.backerup</span> snapshot or{" "}
<span className="font-mono text-slate-300">.json</span> container config.
Anyone with the link can download it.
</p>
</div>
<form onSubmit={handleSubmit} className="space-y-6">
{/* Drop zone */}
<div
className={`relative flex cursor-pointer flex-col items-center justify-center rounded-2xl border-2 border-dashed px-8 py-16 text-center transition ${dragging
? "border-cyan-400 bg-cyan-500/10"
: file
? "border-emerald-500/50 bg-emerald-500/5"
: "border-slate-700 bg-slate-900/50 hover:border-slate-600"
}`}
onClick={() => inputRef.current?.click()}
onDragOver={(e) => { e.preventDefault(); setDragging(true); }}
onDragLeave={() => setDragging(false)}
onDrop={onDrop}
>
<input
ref={inputRef}
type="file"
accept=".backerup,.json"
className="hidden"
onChange={(e) => { const f = e.target.files?.[0]; if (f) pickFile(f); }}
/>
{file ? (
<>
<div className="text-4xl">{isBackerup ? "📦" : "🗂️"}</div>
<p className="mt-3 font-semibold text-white">{file.name}</p>
<p className="mt-1 text-xs text-slate-400">
{formatBytes(file.size)} ·{" "}
<button
type="button"
className="text-cyan-400 hover:underline"
onClick={(e) => { e.stopPropagation(); setFile(null); }}
>
remove
</button>
</p>
</>
) : (
<>
<div className="text-4xl text-slate-600">📁</div>
<p className="mt-4 text-sm font-medium text-slate-300">
Drop a file here or click to browse
</p>
<p className="mt-1 text-xs text-slate-500">
Accepts <span className="font-mono">.backerup</span> and{" "}
<span className="font-mono">.json</span> &mdash; up to 500 MB
</p>
</>
)}
</div>
{/* Display name */}
<div>
<label className="mb-1.5 block text-sm font-medium text-slate-300" htmlFor="displayName">
Display name <span className="text-slate-600">(optional)</span>
</label>
<input
id="displayName"
type="text"
value={displayName}
onChange={(e) => setDisplayName(e.target.value)}
placeholder="e.g. Production Postgres backup"
maxLength={120}
className="w-full rounded-xl border border-slate-700 bg-slate-900 px-4 py-3 text-sm text-slate-200 placeholder-slate-600 outline-none focus:border-cyan-500 transition-colors"
/>
<p className="mt-1 text-xs text-slate-600">Shown instead of the raw filename.</p>
</div>
{/* Group */}
<div>
<label className="mb-1.5 block text-sm font-medium text-slate-300" htmlFor="group">
Group <span className="text-slate-600">(optional)</span>
</label>
<input
id="group"
type="text"
list="group-list"
value={group}
onChange={(e) => setGroup(e.target.value)}
placeholder="e.g. production, homelab, postgres"
maxLength={60}
className="w-full rounded-xl border border-slate-700 bg-slate-900 px-4 py-3 text-sm text-slate-200 placeholder-slate-600 outline-none focus:border-cyan-500 transition-colors"
/>
{existingGroups.length > 0 && (
<datalist id="group-list">
{existingGroups.map((g) => (
<option key={g} value={g} />
))}
</datalist>
)}
<p className="mt-1 text-xs text-slate-600">
Tag this upload so others can filter by group on the browse page.
</p>
</div>
{/* Description */}
<div>
<label className="mb-1.5 block text-sm font-medium text-slate-300" htmlFor="desc">
Description <span className="text-slate-600">(optional)</span>
</label>
<textarea
id="desc"
rows={3}
value={description}
onChange={(e) => setDescription(e.target.value)}
placeholder="e.g. Production Postgres 16 with TimescaleDB extension"
className="w-full rounded-xl border border-slate-700 bg-slate-900 px-4 py-3 text-sm text-slate-200 placeholder-slate-600 outline-none focus:border-cyan-500 transition-colors"
/>
</div>
{/* Warning for .backerup */}
{isBackerup && (
<div className="rounded-xl border border-amber-500/20 bg-amber-500/5 p-4 text-xs text-amber-300">
<strong>Heads up:</strong> .backerup files may contain volume data. Make sure
you are not sharing sensitive database contents or secrets.
</div>
)}
{error && (
<p className="rounded-lg bg-red-500/10 px-4 py-3 text-sm text-red-400">{error}</p>
)}
<button
type="submit"
disabled={!file || uploading}
className="w-full rounded-xl bg-cyan-500 py-3 text-sm font-bold text-slate-900 transition hover:bg-cyan-400 disabled:cursor-not-allowed disabled:opacity-40"
>
{uploading ? "Uploading…" : "Upload & get link"}
</button>
</form>
</div>
);
}
+4634
View File
File diff suppressed because it is too large Load Diff
View File
+14
View File
@@ -0,0 +1,14 @@
[
{
"token": "-jB8pMdeKu",
"originalName": "liquidity-db.config.json",
"displayName": "DB",
"size": 5606,
"type": "config",
"uploadedAt": "2026-05-11T21:18:55.259Z",
"description": "Skibidi Ligma",
"group": "production",
"containerName": "liquidity-db",
"image": "postgres:16-alpine"
}
]
+18
View File
@@ -0,0 +1,18 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";
const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
]);
export default eslintConfig;
+67
View File
@@ -0,0 +1,67 @@
import path from 'path'
import fs from 'fs/promises'
export type FileType = 'backerup' | 'config'
export interface FileRecord {
token: string
originalName: string
displayName?: string
size: number
type: FileType
uploadedAt: string
description?: string
group?: string
containerName?: string
image?: string
}
const DATA_DIR = path.join(process.cwd(), 'data')
const META_FILE = path.join(DATA_DIR, 'meta.json')
const UPLOADS_DIR = path.join(DATA_DIR, 'uploads')
async function ensureDirs() {
await fs.mkdir(UPLOADS_DIR, { recursive: true })
}
export async function readMeta(): Promise<FileRecord[]> {
try {
const text = await fs.readFile(META_FILE, 'utf-8')
return JSON.parse(text) as FileRecord[]
} catch {
return []
}
}
export async function listGroups(): Promise<string[]> {
const records = await readMeta()
const groups = new Set<string>()
for (const r of records) {
if (r.group) groups.add(r.group)
}
return Array.from(groups).sort()
}
async function writeMeta(records: FileRecord[]): Promise<void> {
await ensureDirs()
await fs.writeFile(META_FILE, JSON.stringify(records, null, 2), 'utf-8')
}
export async function addFile(record: FileRecord, buffer: Buffer): Promise<void> {
await ensureDirs()
const dir = path.join(UPLOADS_DIR, record.token)
await fs.mkdir(dir, { recursive: true })
await fs.writeFile(path.join(dir, record.originalName), buffer)
const records = await readMeta()
records.unshift(record)
await writeMeta(records)
}
export async function getFile(token: string): Promise<FileRecord | undefined> {
const records = await readMeta()
return records.find((r) => r.token === token)
}
export function getUploadPath(token: string, originalName: string): string {
return path.join(UPLOADS_DIR, token, originalName)
}
+12
View File
@@ -0,0 +1,12 @@
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
output: "standalone",
experimental: {
serverActions: {
bodySizeLimit: "500mb",
},
},
};
export default nextConfig;
+35
View File
@@ -0,0 +1,35 @@
{
"name": "backerup-website",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
},
"dependencies": {
"nanoid": "^5.1.11",
"next": "16.2.6",
"react": "19.2.4",
"react-dom": "19.2.4"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^25.7.0",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "16.2.6",
"tailwindcss": "^4",
"typescript": "^5"
},
"ignoreScripts": [
"sharp",
"unrs-resolver"
],
"trustedDependencies": [
"sharp",
"unrs-resolver"
]
}
+7
View File
@@ -0,0 +1,7 @@
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};
export default config;
+1
View File
@@ -0,0 +1 @@
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>

After

Width:  |  Height:  |  Size: 391 B

+1
View File
@@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

+1
View File
@@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 128 B

+1
View File
@@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>

After

Width:  |  Height:  |  Size: 385 B

+42
View File
@@ -0,0 +1,42 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./*"
]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts",
"**/*.mts"
],
"exclude": [
"node_modules"
]
}