Endpoint checks, restore tests, and a change log

- Endpoints: HTTP, TCP and TLS checks with answer time, uptime and certificate expiry; failures and expiring certificates become alerts and notifications; linked to a server for maintenance and tags
- Restore tests: record when a backup was restored and how it went; failed tests always alert, overdue ones with a limit set; shown on the Backup coverage page
- Change log: one filterable timeline made from the audit log and the incident record

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-18 23:03:56 +02:00
1 parent c3bc6bbf72
commit 92726568b7
37 files changed
+6918 -21

No files matched your search

+222 -6
View File
@@ -1,6 +1,8 @@
import { useEffect, useState } from "react";
import { Link, useSearchParams } from "react-router-dom";
import { api, type BackupCoverage, type CoverageGuest, type CoverageStatus } from "../api/client";
import { api, type BackupCoverage, type CoverageGuest, type CoverageStatus, type CurrentUser, type RestoreInfo, type RestoreResult, type RestoreStatus, type RestoreTestEntry } from "../api/client";
import { confirmDialog } from "../utils/dialogs";
import { toast } from "../utils/toast";
import Pagination from "../components/Pagination";
import SortableTh from "../components/SortableTh";
import TableToolbar from "../components/TableToolbar";
@@ -30,11 +32,79 @@ const STATUS: Record<CoverageStatus, { label: string; badge: string; hint: strin
const STALE_CHOICES = [1, 2, 3, 7, 14];
const RESTORE: Record<RestoreStatus, { label: string; badge: string }> = {
never: { label: "Never tested", badge: "bg-secondary-lt text-secondary" },
ok: { label: "Restored fine", badge: "bg-green-lt text-green" },
partial: { label: "Partly worked", badge: "bg-yellow-lt text-yellow" },
failed: { label: "Restore failed", badge: "bg-red-lt text-red" },
stale: { label: "Test is old", badge: "bg-yellow-lt text-yellow" },
not_needed: { label: "No need to test", badge: "bg-secondary-lt text-secondary" },
};
const RESULT_WORDS: Record<RestoreResult, string> = { ok: "It restored and worked", partial: "It restored, but not everything worked", failed: "It failed", not_needed: "No need to test this one" };
interface TestDraft {
/** A guest's key, or null for something that isn't a Proxmox guest. */
key: string | null;
label: string;
testedAt: string;
result: RestoreResult;
note: string;
}
const todayIso = () => new Date().toISOString().slice(0, 10);
const ageWords = (r: RestoreInfo) => (r.ageDays === null ? "" : r.ageDays === 0 ? "today" : r.ageDays === 1 ? "yesterday" : `${r.ageDays} days ago`);
/**
* What is and isn't backed up: every Proxmox guest, whether a backup job covers it, when it was last backed up (from Proxmox Backup Server
* snapshots and Proxmox's own backup tasks), and whether that went well — one page instead of an alert per gap.
*/
export default function Backups() {
export default function Backups({ user }: { user?: CurrentUser }) {
const canRecord = user?.role === "admin" || user?.role === "operator";
const isAdmin = user?.role === "admin";
const [tests, setTests] = useState<RestoreTestEntry[] | null>(null);
const [custom, setCustom] = useState<(RestoreInfo & { key: string; label: string })[]>([]);
const [draft, setDraft] = useState<TestDraft | null>(null);
const [saving, setSaving] = useState(false);
function loadTests() {
api.backups
.restoreTests()
.then((res) => {
setTests(res.tests);
setCustom(res.custom);
})
.catch(() => setTests([]));
}
useEffect(loadTests, []);
async function saveTest(e: React.FormEvent) {
e.preventDefault();
if (!draft) return;
setSaving(true);
try {
await api.backups.recordRestoreTest({ key: draft.key ?? undefined, label: draft.label.trim(), testedAt: draft.testedAt, result: draft.result, note: draft.note.trim() || undefined });
toast.success("Recorded.");
setDraft(null);
loadTests();
load();
} catch (err) {
setError(readableError(err));
} finally {
setSaving(false);
}
}
async function removeTest(t: RestoreTestEntry) {
if (!(await confirmDialog({ title: "Remove a restore test", message: `Remove the test of "${t.label}" from ${t.testedAt}?`, confirmLabel: "Remove", danger: true }))) return;
try {
await api.backups.removeRestoreTest(t.id);
loadTests();
load();
} catch (err) {
setError(readableError(err));
}
}
const [params, setParams] = useSearchParams();
const staleParam = Number(params.get("stale"));
const staleDays = STALE_CHOICES.includes(staleParam) ? staleParam : 2;
@@ -83,8 +153,8 @@ export default function Backups() {
if (!sorted) return;
downloadCsv(
"backup-coverage.csv",
["Guest", "Type", "ID", "Node", "Cluster", "In a backup job", "Last backup", "Source", "Status", "Problem"],
sorted.map((r) => [r.name, r.type === "qemu" ? "VM" : "Container", r.vmid, r.node, r.integrationName, r.inJob ? "yes" : "no", r.lastBackupAt ?? "", r.lastSource === "pbs" ? "Backup Server" : r.lastSource === "task" ? "Proxmox task" : "", STATUS[r.status].label, r.failure ?? ""]),
["Guest", "Type", "ID", "Node", "Cluster", "In a backup job", "Last backup", "Source", "Status", "Problem", "Restore test", "Tested on"],
sorted.map((r) => [r.name, r.type === "qemu" ? "VM" : "Container", r.vmid, r.node, r.integrationName, r.inJob ? "yes" : "no", r.lastBackupAt ?? "", r.lastSource === "pbs" ? "Backup Server" : r.lastSource === "task" ? "Proxmox task" : "", STATUS[r.status].label, r.failure ?? "", r.restoreTest ? RESTORE[r.restoreTest.status].label : "", r.restoreTest?.testedAt ?? ""]),
);
}
@@ -168,12 +238,13 @@ export default function Backups() {
<SortableTh<Row> label="In a job" sortKeyName="inJob" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Last backup" sortKeyName="lastBackupAt" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Status" sortKeyName="rank" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<th>Restore test</th>
</tr>
</thead>
<tbody>
{report === null && !error && (
<tr>
<td colSpan={4}>
<td colSpan={5}>
<BlockSkeleton lines={4} />
</td>
</tr>
@@ -209,11 +280,28 @@ export default function Backups() {
</span>
{r.failure && <div className="text-secondary small">{r.failure}</div>}
</td>
<td>
{r.restoreTest && (
<>
<span className={`badge ${RESTORE[r.restoreTest.status].badge}`} title={r.restoreTest.note ?? undefined}>
{RESTORE[r.restoreTest.status].label}
</span>
{r.restoreTest.testedAt && <div className="text-secondary small">{ageWords(r.restoreTest)}</div>}
</>
)}
{canRecord && r.restoreKey && (
<div>
<button type="button" className="btn btn-link btn-sm p-0" onClick={() => setDraft({ key: r.restoreKey!, label: r.name, testedAt: todayIso(), result: "ok", note: "" })}>
Record a test
</button>
</div>
)}
</td>
</tr>
))}
{report !== null && sorted?.length === 0 && (
<tr>
<td colSpan={4} className="text-secondary text-center">
<td colSpan={5} className="text-secondary text-center">
{rows.length === 0 ? (
<>
No Proxmox guests to show. Connect a Proxmox integration under <Link to="/integrations">Integrations</Link>.
@@ -233,6 +321,134 @@ export default function Backups() {
name its guests, so a guest backed up to something other than a Backup Server reads “Unknown” rather than being guessed at. The result is kept for a minute; “Check now” asks again.
</div>
</div>
{draft && (
<form className="card mt-3" onSubmit={saveTest}>
<div className="card-header">
<h3 className="card-title">Record a restore test{draft.key ? ` of ${draft.label}` : ""}</h3>
</div>
<div className="card-body row g-3">
{draft.key === null && (
<div className="col-md-5">
<label className="form-label" htmlFor="rt-label">
What was restored
</label>
<input id="rt-label" className="form-control" required maxLength={120} placeholder="e.g. Photos share, Gitea database" value={draft.label} onChange={(e) => setDraft({ ...draft, label: e.target.value })} />
</div>
)}
<div className="col-md-3">
<label className="form-label" htmlFor="rt-date">
On
</label>
<input id="rt-date" type="date" className="form-control" required max={todayIso()} value={draft.testedAt} onChange={(e) => setDraft({ ...draft, testedAt: e.target.value })} />
</div>
<div className="col-md-4">
<label className="form-label" htmlFor="rt-result">
How it went
</label>
<select id="rt-result" className="form-select" value={draft.result} onChange={(e) => setDraft({ ...draft, result: e.target.value as RestoreResult })}>
{(Object.keys(RESULT_WORDS) as RestoreResult[]).map((r) => (
<option key={r} value={r}>
{RESULT_WORDS[r]}
</option>
))}
</select>
</div>
<div className="col-12">
<label className="form-label" htmlFor="rt-note">
Note (optional)
</label>
<input id="rt-note" className="form-control" maxLength={500} placeholder="e.g. restored to a scratch VM, booted, the database was there" value={draft.note} onChange={(e) => setDraft({ ...draft, note: e.target.value })} />
</div>
</div>
<div className="card-footer d-flex gap-2">
<button type="submit" className="btn btn-primary" disabled={saving || draft.label.trim() === ""}>
{saving ? "Saving…" : "Record it"}
</button>
<button type="button" className="btn" onClick={() => setDraft(null)}>
Cancel
</button>
</div>
</form>
)}
<div className="card mt-3">
<div className="card-header">
<h3 className="card-title">Restore tests</h3>
{canRecord && !draft && (
<div className="card-actions">
<button className="btn btn-sm" onClick={() => setDraft({ key: null, label: "", testedAt: todayIso(), result: "ok", note: "" })}>
Record a test of something else
</button>
</div>
)}
</div>
<div className="card-body text-secondary small pb-0">
A backup nobody has restored is a hope, not a backup. Record each time you try one — for a guest above, or for anything else (a share, a database). A failed test is raised on the
Alerts page; under Settings → Notifications you can also ask to be reminded when a guest with backups hasn&rsquo;t had one in a while{report?.restoreTestDays ? ` (now: ${report.restoreTestDays} days)` : ""}.
</div>
{custom.length > 0 && (
<div className="card-body pb-0">
<div className="text-secondary small mb-1">Other things being tracked</div>
<div className="d-flex flex-wrap gap-2">
{custom.map((c) => (
<span key={c.key} className={`badge ${RESTORE[c.status].badge}`}>
{c.label} · {RESTORE[c.status].label.toLowerCase()} {ageWords(c)}
</span>
))}
</div>
</div>
)}
<div className="table-responsive">
<table className="table table-vcenter card-table table-stack">
<thead>
<tr>
<th>Date</th>
<th>What</th>
<th>Result</th>
<th>Note</th>
{isAdmin && <th className="w-1">Actions</th>}
</tr>
</thead>
<tbody>
{tests === null && (
<tr>
<td colSpan={isAdmin ? 5 : 4}>
<BlockSkeleton lines={2} />
</td>
</tr>
)}
{tests?.map((t) => (
<tr key={t.id}>
<td className="stack-label" data-label="Date">{t.testedAt}</td>
<td>{t.label}</td>
<td>
<span className={`badge ${RESTORE[t.result].badge}`}>{RESTORE[t.result].label}</span>
</td>
<td className="text-secondary stack-wide">
{t.note ?? "—"}
{t.testedBy && <span className="small"> · {t.testedBy}</span>}
</td>
{isAdmin && (
<td className="stack-wide">
<button className="btn btn-sm btn-outline-danger" onClick={() => void removeTest(t)}>
Remove
</button>
</td>
)}
</tr>
))}
{tests !== null && tests.length === 0 && (
<tr>
<td colSpan={isAdmin ? 5 : 4} className="text-secondary text-center">
No restore has been recorded yet.{canRecord ? " After you next try one, record it here." : ""}
</td>
</tr>
)}
</tbody>
</table>
</div>
</div>
</>
);
}