Duplicati: know when a backup failed or has gone quiet

Duplicati reports each operation to a secret address (its own send-http-url option), so
nothing calls Duplicati and no password for it is kept. Each machine is a source; each job
is learned by name and shows its last result, duration, size, changes and a history.
A failed run is a warning (critical from the second in a row); one that has not succeeded
for longer than expected (per job, 2 days by default) is a warning, critical at three
times that. Maintenance on the machine's server silences them; /metrics series added.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-24 21:36:13 +02:00
1 parent 12f2662465
commit 2f082ca5c2
23 files changed
+8047 -4

No files matched your search

+2
View File
@@ -12,6 +12,7 @@ import AlertRules from "./pages/AlertRules";
import HomeAssistant from "./pages/HomeAssistant";
import Ups from "./pages/Ups";
import ServiceLevels from "./pages/ServiceLevels";
import Duplicati from "./pages/Duplicati";
import MyWorkPage from "./pages/MyWork";
import ApiTokens from "./pages/ApiTokens";
import Todo from "./pages/Todo";
@@ -158,6 +159,7 @@ function Shelled({ user }: { user: CurrentUser }) {
<Route path="/home-assistant" element={<HomeAssistant user={user} />} />
<Route path="/ups" element={<Ups user={user} />} />
<Route path="/service-levels" element={<ServiceLevels user={user} />} />
<Route path="/duplicati" element={<Duplicati user={user} />} />
<Route path="/ports" element={<Ports user={user} />} />
<Route path="/secrets" element={<Secrets user={user} />} />
<Route path="/integrations" element={<Integrations user={user} />} />
+64
View File
@@ -1195,6 +1195,62 @@ export interface MonthlyReport {
}
/** A check the app could set up for you, from what it already knows. */
/** A backup job Duplicati reported, as the page shows it. */
export interface DuplicatiBackup {
id: number;
sourceId: number;
sourceName: string;
name: string;
state: "ok" | "warning" | "failed" | "stale";
/** What is wrong, in a sentence, when something is. */
problem: string | null;
lastReportAt: string | null;
lastResult: string | null;
lastSuccessAt: string | null;
durationSeconds: number | null;
examinedFiles: number | null;
sizeBytes: number | null;
addedFiles: number | null;
modifiedFiles: number | null;
deletedFiles: number | null;
warnings: number;
errors: number;
message: string | null;
consecutiveFailures: number;
expectedHours: number;
alert: boolean;
}
export interface DuplicatiSource {
id: number;
name: string;
tokenPrefix: string;
serverId: number | null;
serverName: string | null;
createdBy: string | null;
createdAt: string;
lastReportAt: string | null;
backups: number;
}
export interface DuplicatiOverview {
sources: DuplicatiSource[];
backups: DuplicatiBackup[];
servers: { id: number; name: string }[];
defaultExpectedHours: number;
}
export interface DuplicatiRun {
id: number;
at: string;
result: string;
durationSeconds: number | null;
sizeBytes: number | null;
filesChanged: number | null;
warnings: number;
errors: number;
}
export interface EndpointSuggestion {
key: string;
kind: "http" | "tls";
@@ -2580,6 +2636,14 @@ export const api = {
create: (label: string) => request<{ token: MetricsToken; secret: string }>("/api/metrics-tokens", { method: "POST", body: JSON.stringify({ label }) }),
remove: (id: number) => request<void>(`/api/metrics-tokens/${id}`, { method: "DELETE" }),
},
duplicati: {
overview: () => request<DuplicatiOverview>("/api/duplicati"),
runs: (backupId: number) => request<{ backup: { id: number; name: string }; runs: DuplicatiRun[] }>(`/api/duplicati/backups/${backupId}/runs`),
addSource: (data: { name: string; serverId: number | null }) => request<{ source: DuplicatiSource; token: string; path: string }>("/api/duplicati/sources", { method: "POST", body: JSON.stringify(data) }),
removeSource: (id: number) => request<void>(`/api/duplicati/sources/${id}`, { method: "DELETE" }),
updateBackup: (id: number, data: { expectedHours?: number; alert?: boolean }) => request<{ ok: boolean }>(`/api/duplicati/backups/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
forgetBackup: (id: number) => request<void>(`/api/duplicati/backups/${id}`, { method: "DELETE" }),
},
away: {
get: () => request<AwayView>("/api/away"),
start: (data: { until: string; from?: string | null; criticalThrough: boolean; note?: string }) => request<AwayView>("/api/away", { method: "PUT", body: JSON.stringify(data) }),
+2
View File
@@ -9,6 +9,7 @@ import {
IconHome2,
IconBatteryCharging,
IconTargetArrow,
IconDatabaseExport,
IconAdjustmentsAlt,
IconChecklist,
IconListDetails,
@@ -93,6 +94,7 @@ export const NAV: NavEntry[] = [
items: [
{ to: "/backups", label: "Backup coverage", icon: <IconCopyCheck size={20} /> },
{ to: "/pbs", label: "Proxmox Backup", icon: <IconShieldCheck size={20} /> },
{ to: "/duplicati", label: "Duplicati", icon: <IconDatabaseExport size={20} /> },
],
},
{
+391
View File
@@ -0,0 +1,391 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type CurrentUser, type DuplicatiBackup, type DuplicatiOverview, type DuplicatiRun } from "../api/client";
import CopyButton from "../components/CopyButton";
import DetailDrawer from "../components/DetailDrawer";
import EmptyState from "../components/EmptyState";
import { ErrorNotice } from "../components/Notice";
import { BlockSkeleton } from "../components/Skeleton";
import TimeAgo from "../components/TimeAgo";
import { formatBytes } from "./settings/StorageSettings";
import { confirmDialog } from "../utils/dialogs";
import { readableError } from "../utils/errors";
import { toast } from "../utils/toast";
const STATE: Record<DuplicatiBackup["state"], { label: string; cls: string }> = {
ok: { label: "In order", cls: "bg-green-lt text-green" },
warning: { label: "Warnings", cls: "bg-yellow-lt text-yellow" },
failed: { label: "Failed", cls: "bg-red-lt text-red" },
stale: { label: "Overdue", cls: "bg-red-lt text-red" },
};
/** What needs a look comes first. */
const RANK: Record<DuplicatiBackup["state"], number> = { failed: 0, stale: 1, warning: 2, ok: 3 };
const EVERY = [
{ hours: 6, label: "6 hours" },
{ hours: 12, label: "12 hours" },
{ hours: 24, label: "day" },
{ hours: 36, label: "36 hours" },
{ hours: 48, label: "2 days" },
{ hours: 72, label: "3 days" },
{ hours: 168, label: "week" },
{ hours: 336, label: "2 weeks" },
{ hours: 720, label: "30 days" },
];
const took = (s: number | null) => (s === null ? "—" : s < 60 ? `${s} s` : s < 3600 ? `${Math.round(s / 60)} min` : `${Math.floor(s / 3600)} h ${Math.round((s % 3600) / 60)} min`);
function RunBadge({ result }: { result: string | null }) {
if (!result) return <span className="text-secondary">—</span>;
const good = /^success$/i.test(result);
const warn = /^warning$/i.test(result);
return <span className={`badge ${good ? "bg-green-lt text-green" : warn ? "bg-yellow-lt text-yellow" : "bg-red-lt text-red"}`}>{result}</span>;
}
/** The last runs of one backup, newest first. */
function History({ backup, onClose }: { backup: DuplicatiBackup; onClose: () => void }) {
const [runs, setRuns] = useState<DuplicatiRun[] | null>(null);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
api.duplicati
.runs(backup.id)
.then((r) => setRuns(r.runs))
.catch((err) => setError(readableError(err)));
}, [backup.id]);
return (
<DetailDrawer title={backup.name} subtitle={`${backup.sourceName} — the last backups`} onClose={onClose}>
<ErrorNotice error={error} />
{runs === null && !error && <BlockSkeleton lines={4} />}
{runs?.length === 0 && <EmptyState title="No runs yet" />}
{runs && runs.length > 0 && (
<div className="table-responsive">
<table className="table table-vcenter table-sm">
<thead>
<tr>
<th>When</th>
<th>Result</th>
<th className="text-end">Took</th>
<th className="text-end">Size</th>
<th className="text-end">Changed</th>
</tr>
</thead>
<tbody>
{runs.map((r) => (
<tr key={r.id}>
<td>
<TimeAgo value={r.at} />
</td>
<td>
<RunBadge result={r.result} />
{(r.errors > 0 || r.warnings > 0) && (
<div className="text-secondary small">
{r.errors > 0 ? `${r.errors} error${r.errors === 1 ? "" : "s"}` : ""}
{r.errors > 0 && r.warnings > 0 ? ", " : ""}
{r.warnings > 0 ? `${r.warnings} warning${r.warnings === 1 ? "" : "s"}` : ""}
</div>
)}
</td>
<td className="text-end">{took(r.durationSeconds)}</td>
<td className="text-end">{r.sizeBytes === null ? "—" : formatBytes(r.sizeBytes)}</td>
<td className="text-end">{r.filesChanged === null ? "—" : r.filesChanged.toLocaleString()}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</DetailDrawer>
);
}
/** What to paste into Duplicati, shown once after a machine is added. */
function Address({ path, name, onDone }: { path: string; name: string; onDone: () => void }) {
const url = `${window.location.origin}${path}`;
const options = `--send-http-url=${url}\n--send-http-result-output-format=Json\n--send-http-level=All`;
return (
<div className="border border-success rounded p-3 mb-3">
<div className="fw-bold mb-1">Point Duplicati on {name} at this app</div>
<div className="text-secondary mb-2">Copy it now — the address can&rsquo;t be shown again. If it is lost, remove the machine and add it again.</div>
<ol className="mb-2">
<li>In Duplicati, open <strong>Settings → Default options</strong> (so every job on that machine reports) and add these three <strong>advanced options</strong>:</li>
</ol>
<div className="input-group mb-2">
<textarea className="form-control" rows={3} readOnly value={options} aria-label="The three Duplicati options" onFocus={(e) => e.currentTarget.select()} style={{ fontFamily: "monospace", fontSize: "0.8125rem" }} />
<CopyButton text={options} />
</div>
<div className="text-secondary small mb-2">
<code>send-http-level=All</code> matters: Duplicati otherwise only reports problems, and a backup that quietly stops reporting could not be told from one that works. Each backup shows up here after its next run.
</div>
<button className="btn btn-sm" onClick={onDone}>
Done
</button>
</div>
);
}
/** Whether the backups Duplicati makes are being made: each machine's jobs, how the last run went, how long it took, how big it is — and what has gone quiet. */
export default function Duplicati({ user }: { user: CurrentUser }) {
const isAdmin = user.role === "admin";
const canEdit = isAdmin || user.role === "operator";
const [data, setData] = useState<DuplicatiOverview | null>(null);
const [error, setError] = useState<string | null>(null);
const [adding, setAdding] = useState(false);
const [name, setName] = useState("");
const [serverId, setServerId] = useState("");
const [busy, setBusy] = useState(false);
const [fresh, setFresh] = useState<{ path: string; name: string } | null>(null);
const [history, setHistory] = useState<DuplicatiBackup | null>(null);
function load() {
api.duplicati
.overview()
.then((d) => {
setData(d);
setError(null);
})
.catch((err) => setError(readableError(err)));
}
useEffect(() => {
load();
const t = setInterval(load, 60_000);
return () => clearInterval(t);
}, []);
async function addSource(e: React.FormEvent) {
e.preventDefault();
setBusy(true);
setError(null);
try {
const res = await api.duplicati.addSource({ name: name.trim(), serverId: serverId === "" ? null : Number(serverId) });
setFresh({ path: res.path, name: res.source.name });
setAdding(false);
setName("");
setServerId("");
load();
} catch (err) {
setError(readableError(err));
} finally {
setBusy(false);
}
}
async function removeSource(id: number, label: string) {
if (!(await confirmDialog({ title: "Remove a machine", message: `Remove "${label}" with its backups and their history? Its address stops working.`, confirmLabel: "Remove", danger: true }))) return;
try {
await api.duplicati.removeSource(id);
load();
} catch (err) {
setError(readableError(err));
}
}
async function patch(b: DuplicatiBackup, change: { expectedHours?: number; alert?: boolean }) {
try {
await api.duplicati.updateBackup(b.id, change);
load();
} catch (err) {
toast.error(readableError(err));
}
}
async function forget(b: DuplicatiBackup) {
if (!(await confirmDialog({ title: "Forget a backup", message: `Forget "${b.name}" on ${b.sourceName} and its history? If Duplicati reports it again, it is learned again.`, confirmLabel: "Forget", danger: true }))) return;
try {
await api.duplicati.forgetBackup(b.id);
load();
} catch (err) {
setError(readableError(err));
}
}
const problems = data?.backups.filter((b) => b.state === "failed" || b.state === "stale").length ?? 0;
return (
<>
<div className="d-flex align-items-center mb-1">
<h2 className="page-title mb-0">Duplicati</h2>
{isAdmin && !adding && (
<button className="btn btn-primary ms-auto" onClick={() => setAdding(true)}>
Add a machine
</button>
)}
</div>
<p className="text-secondary">
Whether the backups Duplicati makes are being made. Duplicati tells this app how each backup went (its own <em>send-http-url</em> option), so nothing here calls Duplicati and no password for it is kept. A backup that <strong>fails</strong>,
or has <strong>not succeeded for longer than it should</strong>, is an alert — see <Link to="/alerts">Alerts</Link>.
</p>
<ErrorNotice error={error} />
{fresh && <Address path={fresh.path} name={fresh.name} onDone={() => setFresh(null)} />}
{adding && data && (
<form className="card mb-3" onSubmit={addSource}>
<div className="card-header">
<h3 className="card-title">Add a machine running Duplicati</h3>
</div>
<div className="card-body row g-3">
<div className="col-md-5">
<label className="form-label" htmlFor="dup-name">
Name
</label>
<input id="dup-name" className="form-control" required maxLength={100} placeholder="e.g. Jackie" value={name} onChange={(e) => setName(e.target.value)} />
</div>
<div className="col-md-7">
<label className="form-label" htmlFor="dup-server">
It runs on the server
</label>
<select id="dup-server" className="form-select" value={serverId} onChange={(e) => setServerId(e.target.value)}>
<option value="">— none in particular —</option>
{data.servers.map((s) => (
<option key={s.id} value={s.id}>
{s.name}
</option>
))}
</select>
<div className="form-hint text-secondary small mt-1">Maintenance on that server silences these backups&rsquo; alerts.</div>
</div>
</div>
<div className="card-footer d-flex gap-2">
<button className="btn btn-primary" disabled={busy || name.trim() === ""}>
{busy ? "Adding…" : "Add and show its address"}
</button>
<button type="button" className="btn" onClick={() => setAdding(false)}>
Cancel
</button>
</div>
</form>
)}
{!data && !error && <BlockSkeleton lines={4} />}
{data && data.sources.length === 0 && !adding && (
<div className="card">
<div className="card-body">
<EmptyState
title="No machine reports yet"
hint="Add each machine that runs Duplicati: you get an address to give Duplicati once, and every backup it makes then shows up here with how it went."
action={isAdmin ? { label: "Add a machine", onClick: () => setAdding(true) } : undefined}
/>
</div>
</div>
)}
{data && data.sources.length > 0 && (
<div className="row row-cards mb-3">
{data.sources.map((s) => (
<div className="col-sm-6 col-lg-3" key={s.id}>
<div className="card card-sm h-100">
<div className="card-body">
<div className="d-flex align-items-start">
<div>
<strong>{s.name}</strong>
<div className="text-secondary small">
{s.backups} backup{s.backups === 1 ? "" : "s"}
{s.serverId !== null && s.serverName ? (
<>
{" "}
· <Link to={`/servers/${s.serverId}`}>{s.serverName}</Link>
</>
) : null}
</div>
<div className="small">{s.lastReportAt ? <>last heard <TimeAgo value={s.lastReportAt} /></> : <span className="text-secondary">nothing yet</span>}</div>
</div>
{isAdmin && (
<button className="btn btn-sm btn-outline-danger ms-auto" onClick={() => void removeSource(s.id, s.name)} aria-label={`Remove ${s.name}`}>
Remove
</button>
)}
</div>
</div>
</div>
</div>
))}
</div>
)}
{data && data.backups.length > 0 && (
<div className="card">
<div className="card-header">
<h3 className="card-title">
Backups
{problems > 0 && <span className="text-red fw-normal ms-2">{problems} need a look</span>}
</h3>
</div>
<div className="table-responsive">
<table className="table table-vcenter card-table">
<thead>
<tr>
<th>Backup</th>
<th>Last good backup</th>
<th className="text-end">Took</th>
<th className="text-end">Size</th>
<th className="text-end">Changed</th>
<th>Expected every</th>
<th>State</th>
<th className="w-1">Actions</th>
</tr>
</thead>
<tbody>
{[...data.backups]
.sort((a, b) => RANK[a.state] - RANK[b.state] || a.sourceName.localeCompare(b.sourceName) || a.name.localeCompare(b.name))
.map((b) => (
<tr key={b.id}>
<td>
<strong>{b.name}</strong>
<div className="text-secondary small">{b.sourceName}</div>
</td>
<td>
{b.lastSuccessAt ? <TimeAgo value={b.lastSuccessAt} /> : <span className="text-secondary">never succeeded</span>}
<div>
<RunBadge result={b.lastResult} />
</div>
</td>
<td className="text-end">{took(b.durationSeconds)}</td>
<td className="text-end">{b.sizeBytes === null ? "—" : formatBytes(b.sizeBytes)}</td>
<td className="text-end">{b.addedFiles === null && b.modifiedFiles === null && b.deletedFiles === null ? "—" : ((b.addedFiles ?? 0) + (b.modifiedFiles ?? 0) + (b.deletedFiles ?? 0)).toLocaleString()}</td>
<td>
{canEdit ? (
<select className="form-select form-select-sm w-auto" aria-label={`How often ${b.name} on ${b.sourceName} should succeed`} value={b.expectedHours} onChange={(e) => void patch(b, { expectedHours: Number(e.target.value) })}>
{EVERY.some((o) => o.hours === b.expectedHours) ? null : <option value={b.expectedHours}>{b.expectedHours} hours</option>}
{EVERY.map((o) => (
<option key={o.hours} value={o.hours}>
{o.label}
</option>
))}
</select>
) : (
`${b.expectedHours} h`
)}
</td>
<td>
<span className={`badge ${STATE[b.state].cls}`}>{STATE[b.state].label}</span>
{b.problem && <div className="text-secondary small">{b.problem}</div>}
{!b.alert && <div className="text-secondary small">no alert</div>}
</td>
<td>
<div className="btn-list flex-nowrap">
<button className="btn btn-sm" onClick={() => setHistory(b)}>
History
</button>
{canEdit && (
<>
<button className="btn btn-sm btn-outline-secondary" onClick={() => void patch(b, { alert: !b.alert })}>
{b.alert ? "Mute" : "Alert"}
</button>
<button className="btn btn-sm btn-outline-danger" onClick={() => void forget(b)}>
Forget
</button>
</>
)}
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)}
{history && <History backup={history} onClose={() => setHistory(null)} />}
</>
);
}