Show what Duplicati's warnings said, and let a job alert on them
The first twenty warning messages of each run are kept with the run and shown on the job and in its history. A job can be set to raise a warning-level alert when its last run finished with warnings (off by default; a muted job raises nothing; maintenance on the machine's server silences it). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d78aba8bf9
commit
64961b1141
14 files changed
+9241
-24
No files matched your search
@@ -2073,9 +2073,13 @@ export interface DuplicatiBackup {
|
||||
warnings: number;
|
||||
errors: number;
|
||||
message: string | null;
|
||||
/** What the last run's warnings said (up to 20). */
|
||||
warningMessages: string[];
|
||||
consecutiveFailures: number;
|
||||
expectedHours: number;
|
||||
alert: boolean;
|
||||
/** Raise an alert when the last run finished with warnings. */
|
||||
alertWarnings: boolean;
|
||||
}
|
||||
|
||||
export interface DuplicatiSource {
|
||||
@@ -2106,6 +2110,8 @@ export interface DuplicatiRun {
|
||||
filesChanged: number | null;
|
||||
warnings: number;
|
||||
errors: number;
|
||||
/** What this run's warnings said (up to 20). */
|
||||
warningMessages: string[];
|
||||
}
|
||||
|
||||
export interface EndpointSuggestion {
|
||||
@@ -3634,7 +3640,7 @@ export const api = {
|
||||
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) }),
|
||||
updateBackup: (id: number, data: { expectedHours?: number; alert?: boolean; alertWarnings?: 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: {
|
||||
|
||||
@@ -43,6 +43,26 @@ function RunBadge({ result }: { result: string | null }) {
|
||||
return <span className={`badge ${good ? "bg-green-lt text-green" : warn ? "bg-yellow-lt text-yellow" : "bg-red-lt text-red"}`}>{result}</span>;
|
||||
}
|
||||
|
||||
/** What a run's warnings said, folded under "N warnings" so a long list does not crowd the table. */
|
||||
function Warnings({ count, messages, label }: { count: number; messages: string[]; label?: string }) {
|
||||
if (count === 0 && messages.length === 0) return null;
|
||||
const text = label ?? `${count} warning${count === 1 ? "" : "s"}`;
|
||||
if (messages.length === 0) return <div className="text-secondary small">{text}</div>;
|
||||
return (
|
||||
<details className="small">
|
||||
<summary className="text-secondary">{text}</summary>
|
||||
<ul className="mb-0 ps-3">
|
||||
{messages.map((m, i) => (
|
||||
<li key={i} className="text-break">
|
||||
{m}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{count > messages.length && <div className="text-secondary">…and {count - messages.length} more that Duplicati did not include</div>}
|
||||
</details>
|
||||
);
|
||||
}
|
||||
|
||||
/** The last runs of one backup, newest first. */
|
||||
function History({ backup, onClose }: { backup: DuplicatiBackup; onClose: () => void }) {
|
||||
const [runs, setRuns] = useState<DuplicatiRun[] | null>(null);
|
||||
@@ -78,13 +98,12 @@ function History({ backup, onClose }: { backup: DuplicatiBackup; onClose: () =>
|
||||
</td>
|
||||
<td>
|
||||
<RunBadge result={r.result} />
|
||||
{(r.errors > 0 || r.warnings > 0) && (
|
||||
{r.errors > 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"}` : ""}
|
||||
{r.errors} error{r.errors === 1 ? "" : "s"}
|
||||
</div>
|
||||
)}
|
||||
<Warnings count={r.warnings} messages={r.warningMessages} />
|
||||
</td>
|
||||
<td className="text-end">{took(r.durationSeconds)}</td>
|
||||
<td className="text-end">{r.sizeBytes === null ? "—" : formatBytes(r.sizeBytes)}</td>
|
||||
@@ -180,7 +199,7 @@ export default function Duplicati({ user }: { user: CurrentUser }) {
|
||||
}
|
||||
}
|
||||
|
||||
async function patch(b: DuplicatiBackup, change: { expectedHours?: number; alert?: boolean }) {
|
||||
async function patch(b: DuplicatiBackup, change: { expectedHours?: number; alert?: boolean; alertWarnings?: boolean }) {
|
||||
try {
|
||||
await api.duplicati.updateBackup(b.id, change);
|
||||
load();
|
||||
@@ -213,7 +232,7 @@ export default function Duplicati({ user }: { user: CurrentUser }) {
|
||||
</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>.
|
||||
or has <strong>not succeeded for longer than it should</strong>, is an alert — see <Link to="/alerts">Alerts</Link>. A run that finishes with <strong>warnings</strong> still counts as a good backup; open a job’s warnings to see what they said, and switch on <em>Alert on warnings</em> for the jobs where they matter.
|
||||
</p>
|
||||
<ErrorNotice error={error} />
|
||||
{fresh && <Address path={fresh.path} name={fresh.name} onDone={() => setFresh(null)} />}
|
||||
@@ -359,7 +378,10 @@ export default function Duplicati({ user }: { user: CurrentUser }) {
|
||||
<td>
|
||||
<span className={`badge ${STATE[b.state].cls}`}>{STATE[b.state].label}</span>
|
||||
{b.problem && <div className="text-secondary small">{b.problem}</div>}
|
||||
{b.state === "warning" && !b.problem && <Warnings count={b.warnings} messages={b.warningMessages} label={`${b.warnings} warning${b.warnings === 1 ? "" : "s"} in the last run`} />}
|
||||
{b.problem && b.state === "warning" && <Warnings count={b.warnings} messages={b.warningMessages} label="All the warnings" />}
|
||||
{!b.alert && <div className="text-secondary small">no alert</div>}
|
||||
{b.alert && b.alertWarnings && <div className="text-secondary small">alerts on warnings</div>}
|
||||
</td>
|
||||
<td>
|
||||
<div className="btn-list flex-nowrap">
|
||||
@@ -371,6 +393,11 @@ export default function Duplicati({ user }: { user: CurrentUser }) {
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={() => void patch(b, { alert: !b.alert })}>
|
||||
{b.alert ? "Mute" : "Alert"}
|
||||
</button>
|
||||
{b.alert && (
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={() => void patch(b, { alertWarnings: !b.alertWarnings })} title="Whether a run that finishes with warnings raises an alert (it counts as a good backup either way)">
|
||||
{b.alertWarnings ? "Stop warning alerts" : "Alert on warnings"}
|
||||
</button>
|
||||
)}
|
||||
<button className="btn btn-sm btn-outline-danger" onClick={() => void forget(b)}>
|
||||
Forget
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user