Say what the last Duplicati report was, so a machine with no jobs explains itself
Each machine's card shows whether the last report was a backup, another operation that was set aside, or one that could not be read (with the reason), and counts of each since it was added. Administrators can see the start of an unreadable report. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
64961b1141
commit
e517de35af
11 files changed
+9248
-9
No files matched your search
@@ -157,6 +157,7 @@ That works on every Duplicati version, needs no login handshake and leaves nothi
|
|||||||
warnings and errors, the first message and **what the warnings said** (JSON format only; up to twenty, each cut at 500 characters, kept with the run). A job is learned from its first report, by name; the same name on another machine is another job.
|
warnings and errors, the first message and **what the warnings said** (JSON format only; up to twenty, each cut at 500 characters, kept with the run). A job is learned from its first report, by name; the same name on another machine is another job.
|
||||||
- **The address is the access.** It is a long random token (stored only as a SHA-256 hash, shown once); all it allows is to say how a backup went. It answers a wrong token with "not found", limits requests per address, and takes POST or PUT. Removing the machine ends it.
|
- **The address is the access.** It is a long random token (stored only as a SHA-256 hash, shown once); all it allows is to say how a backup went. It answers a wrong token with "not found", limits requests per address, and takes POST or PUT. Removing the machine ends it.
|
||||||
- **Not verified against every Duplicati version** — the report fields are read defensively from Duplicati's published output (the results at the top or under `Data`, the job's name among `Extra`). A report the app cannot read is answered "OK (not a report this app can read)" and the page does not learn from it.
|
- **Not verified against every Duplicati version** — the report fields are read defensively from Duplicati's published output (the results at the top or under `Data`, the job's name among `Extra`). A report the app cannot read is answered "OK (not a report this app can read)" and the page does not learn from it.
|
||||||
|
- **Why a machine has no jobs.** "Last heard" only says something arrived on the address. Each machine's card on the page also says **what the last report was** — a backup (with the job and how it ended), another operation that was set aside (compact, repair, test … only a *Backup* makes a job), or one that **could not be read** with the reason (no `ParsedResult`, not valid JSON …) — and how many of each have come since the machine was added. Administrators can open **What was sent** to see the first 600 characters of an unreadable report, to see its form; others see the reason but not the text. A machine with no job yet and only set-aside reports is told to check `--send-http-level=All`.
|
||||||
- What it does with them — alerts, `/metrics`, the history — is in [MONITORING.md](docs/MONITORING.md#duplicati-backups).
|
- What it does with them — alerts, `/metrics`, the history — is in [MONITORING.md](docs/MONITORING.md#duplicati-backups).
|
||||||
|
|
||||||
### Proxmox Backup Server
|
### Proxmox Backup Server
|
||||||
|
|||||||
+2
-1
@@ -248,7 +248,8 @@ Duplicati tells this app how each backup went ([INTEGRATIONS.md](../INTEGRATIONS
|
|||||||
| **Failed** | The last run ended in `Error` or `Fatal` | warning; **critical from the second failure in a row** |
|
| **Failed** | The last run ended in `Error` or `Fatal` | warning; **critical from the second failure in a row** |
|
||||||
| **Overdue** | It has not succeeded for longer than it is **expected** to — 2 days unless you set it per job (6 hours to 90 days) | warning; **critical at three times that** |
|
| **Overdue** | It has not succeeded for longer than it is **expected** to — 2 days unless you set it per job (6 hours to 90 days) | warning; **critical at three times that** |
|
||||||
|
|
||||||
The alert says which job, on which machine, why (the first error Duplicati reported) and when the last good backup was. Only the *Backup* operation counts: a compact, a repair or a verification does not say whether the data is safe. A job can be **muted** (no alert; it is still listed),
|
The alert says which job, on which machine, why (the first error Duplicati reported) and when the last good backup was. Only the *Backup* operation counts: a compact, a repair or a verification does not say whether the data is safe. A machine that is heard but has no jobs says why on its card (the last report was another operation, or could not be read, with counts since it was added) — see [INTEGRATIONS.md](../INTEGRATIONS.md#duplicati).
|
||||||
|
A job can be **muted** (no alert; it is still listed),
|
||||||
**Alert on warnings** (an operator's button on each job, off until switched on — some jobs always have a few, and a backup with warnings is still a backup) raises a warning-level alert while the job's last run had warnings, naming the job, how many there were and the first thing they said; the next clean run ends it. A job that is muted raises nothing, this included. Maintenance on the server silences it like the others.
|
**Alert on warnings** (an operator's button on each job, off until switched on — some jobs always have a few, and a backup with warnings is still a backup) raises a warning-level alert while the job's last run had warnings, naming the job, how many there were and the first thing they said; the next clean run ends it. A job that is muted raises nothing, this included. Maintenance on the server silences it like the others.
|
||||||
A job can also be muted, and one that no longer exists can be **forgotten** (with its history; if Duplicati reports it again it is learned again). Each machine can be tied to a server, so **maintenance on that server silences its backups' alerts**.
|
A job can also be muted, and one that no longer exists can be **forgotten** (with its history; if Duplicati reports it again it is learned again). Each machine can be tied to a server, so **maintenance on that server silences its backups' alerts**.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `duplicati_sources` ADD `last_report` text;
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -624,6 +624,13 @@
|
|||||||
"when": 1794262055100,
|
"when": 1794262055100,
|
||||||
"tag": "0088_grey_silhouette",
|
"tag": "0088_grey_silhouette",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 89,
|
||||||
|
"version": "6",
|
||||||
|
"when": 1794263161221,
|
||||||
|
"tag": "0089_military_tombstone",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1675,6 +1675,7 @@ export const duplicatiSources = sqliteTable("duplicati_sources", {
|
|||||||
.notNull()
|
.notNull()
|
||||||
.default(sql`(current_timestamp)`),
|
.default(sql`(current_timestamp)`),
|
||||||
lastReportAt: text("last_report_at"), // ISO
|
lastReportAt: text("last_report_at"), // ISO
|
||||||
|
lastReport: text("last_report"), // JSON: what the last report turned out to be, and how many of each kind there have been (see services/duplicati.ts, SourceActivity)
|
||||||
});
|
});
|
||||||
|
|
||||||
// One backup job of one source, as its last report left it. A job is learned from its first report (by name) and is expected to succeed every `expectedHours`.
|
// One backup job of one source, as its last report left it. A job is learned from its first report (by name) and is expected to succeed every `expectedHours`.
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ duplicatiRouter.use(requireAuth);
|
|||||||
const idOf = (v: string) => (/^\d+$/.test(v) ? Number(v) : NaN);
|
const idOf = (v: string) => (/^\d+$/.test(v) ? Number(v) : NaN);
|
||||||
|
|
||||||
/** Every machine reporting, every backup job and where it stands: for everyone signed in, like the backup pages. */
|
/** Every machine reporting, every backup job and where it stands: for everyone signed in, like the backup pages. */
|
||||||
duplicatiRouter.get("/", asyncHandler(async (_req, res) => {
|
duplicatiRouter.get("/", asyncHandler(async (req, res) => {
|
||||||
const { sources, backups } = await listAll();
|
const { sources, backups } = await listAll();
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const serverNames = new Map((await db.select({ id: servers.id, name: servers.name }).from(servers)).map((s) => [s.id, s.name]));
|
const serverNames = new Map((await db.select({ id: servers.id, name: servers.name }).from(servers)).map((s) => [s.id, s.name]));
|
||||||
const problems = duplicatiProblems(sources, backups, now);
|
const problems = duplicatiProblems(sources, backups, now);
|
||||||
res.json({
|
res.json({
|
||||||
sources: sources.map((s) => ({ ...publicSource(s), serverName: s.serverId !== null ? (serverNames.get(s.serverId) ?? null) : null, backups: backups.filter((b) => b.sourceId === s.id).length })),
|
sources: sources.map((s) => ({ ...publicSource(s, req.currentUser?.role === "admin"), serverName: s.serverId !== null ? (serverNames.get(s.serverId) ?? null) : null, backups: backups.filter((b) => b.sourceId === s.id).length })),
|
||||||
backups: backups.map((b) => ({ ...b, warningMessages: unpackMessages(b.warningMessages), state: backupState(b, now), sourceName: sources.find((s) => s.id === b.sourceId)?.name ?? "", problem: problems.find((p) => new RegExp(`^duplicati-(failed|stale|warnings):${b.id}(:|$)`).test(p.key))?.message ?? null })),
|
backups: backups.map((b) => ({ ...b, warningMessages: unpackMessages(b.warningMessages), state: backupState(b, now), sourceName: sources.find((s) => s.id === b.sourceId)?.name ?? "", problem: problems.find((p) => new RegExp(`^duplicati-(failed|stale|warnings):${b.id}(:|$)`).test(p.key))?.message ?? null })),
|
||||||
servers: [...serverNames].map(([id, name]) => ({ id, name })).sort((a, b) => a.name.localeCompare(b.name)),
|
servers: [...serverNames].map(([id, name]) => ({ id, name })).sort((a, b) => a.name.localeCompare(b.name)),
|
||||||
defaultExpectedHours: DEFAULT_EXPECTED_HOURS,
|
defaultExpectedHours: DEFAULT_EXPECTED_HOURS,
|
||||||
|
|||||||
@@ -180,6 +180,66 @@ export async function sourceForToken(token: string): Promise<SourceRow | null> {
|
|||||||
return (await db.select().from(duplicatiSources).where(eq(duplicatiSources.tokenHash, hash(token))).limit(1))[0] ?? null;
|
return (await db.select().from(duplicatiSources).where(eq(duplicatiSources.tokenHash, hash(token))).limit(1))[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** What the last report on an address turned out to be, so the page can say why a machine that is being heard has no jobs. */
|
||||||
|
export interface SourceActivity {
|
||||||
|
/** When it arrived (ISO). */
|
||||||
|
at: string;
|
||||||
|
/** "recorded": a backup, written down. "set_aside": a report about something other than a backup. "unreadable": not a report this app can use. */
|
||||||
|
outcome: "recorded" | "set_aside" | "unreadable";
|
||||||
|
/** The operation it was about (Backup, Compact, Repair …), when it said. */
|
||||||
|
operation: string | null;
|
||||||
|
/** How it ended (Success, Warning …), when it said. */
|
||||||
|
result: string | null;
|
||||||
|
/** The job it was about, when it said. */
|
||||||
|
job: string | null;
|
||||||
|
/** For an unreadable one: what was wrong with it, in a sentence. */
|
||||||
|
reason: string | null;
|
||||||
|
/** For an unreadable one: the start of what was sent, to see its form (shown to administrators only). */
|
||||||
|
sample: string | null;
|
||||||
|
/** How many reports of each kind have come since the machine was added. */
|
||||||
|
counts: { recorded: number; setAside: number; unreadable: number };
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MAX_SAMPLE = 600;
|
||||||
|
|
||||||
|
/** Pure: why a body is not a report this app can use, in a sentence, and the start of it. Read for the same two forms parseReport reads. */
|
||||||
|
export function explainUnreadable(body: unknown): { reason: string; sample: string | null } {
|
||||||
|
const text = typeof body === "string" ? body.trim() : "";
|
||||||
|
if (text === "") return { reason: "the body was empty (or not text) — Duplicati should post its result as text or JSON", sample: null };
|
||||||
|
const sample = text.slice(0, MAX_SAMPLE);
|
||||||
|
if (text.startsWith("{")) {
|
||||||
|
let payload: Record<string, unknown> | null = null;
|
||||||
|
try {
|
||||||
|
payload = obj(JSON.parse(text));
|
||||||
|
} catch {
|
||||||
|
return { reason: "it looks like JSON but is not valid JSON (cut short, perhaps)", sample };
|
||||||
|
}
|
||||||
|
const data = Object.keys(obj(payload.Data)).length > 0 ? obj(payload.Data) : payload;
|
||||||
|
const keys = Object.keys(data).slice(0, 8).join(", ");
|
||||||
|
return { reason: `JSON without a ParsedResult field (it has: ${keys || "nothing"})`, sample };
|
||||||
|
}
|
||||||
|
return { reason: "not JSON, and no \"ParsedResult:\" line in it — set send-http-result-output-format=Json (or leave the default text, which has that line)", sample };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pure: the activity after one more report. */
|
||||||
|
export function nextActivity(previous: SourceActivity | null, at: string, report: Pick<SourceActivity, "outcome" | "operation" | "result" | "job" | "reason" | "sample">): SourceActivity {
|
||||||
|
const counts = { recorded: previous?.counts.recorded ?? 0, setAside: previous?.counts.setAside ?? 0, unreadable: previous?.counts.unreadable ?? 0 };
|
||||||
|
if (report.outcome === "recorded") counts.recorded++;
|
||||||
|
else if (report.outcome === "set_aside") counts.setAside++;
|
||||||
|
else counts.unreadable++;
|
||||||
|
return { at, ...report, counts };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function unpackActivity(stored: string | null): SourceActivity | null {
|
||||||
|
if (!stored) return null;
|
||||||
|
try {
|
||||||
|
const v = JSON.parse(stored) as SourceActivity;
|
||||||
|
return v && typeof v === "object" && typeof v.outcome === "string" && v.counts ? v : null;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type RecordOutcome = { recorded: true; backupId: number; result: string } | { recorded: false; reason: "unknown_token" | "unreadable" | "not_a_backup" };
|
export type RecordOutcome = { recorded: true; backupId: number; result: string } | { recorded: false; reason: "unknown_token" | "unreadable" | "not_a_backup" };
|
||||||
|
|
||||||
/** Reads a report that arrived on a secret address and writes it down. Other operations than a backup are said to have been seen and set aside. */
|
/** Reads a report that arrived on a secret address and writes it down. Other operations than a backup are said to have been seen and set aside. */
|
||||||
@@ -187,10 +247,22 @@ export async function recordReport(token: string, body: unknown, now: Date = new
|
|||||||
const source = await sourceForToken(token);
|
const source = await sourceForToken(token);
|
||||||
if (!source) return { recorded: false, reason: "unknown_token" };
|
if (!source) return { recorded: false, reason: "unknown_token" };
|
||||||
const nowIso = now.toISOString();
|
const nowIso = now.toISOString();
|
||||||
await db.update(duplicatiSources).set({ lastReportAt: nowIso }).where(eq(duplicatiSources.id, source.id));
|
const previous = unpackActivity(source.lastReport);
|
||||||
|
/** Writes down that a report came, and what it was. */
|
||||||
|
const note = async (what: Parameters<typeof nextActivity>[2]) => {
|
||||||
|
await db.update(duplicatiSources).set({ lastReportAt: nowIso, lastReport: JSON.stringify(nextActivity(previous, nowIso, what)) }).where(eq(duplicatiSources.id, source.id));
|
||||||
|
};
|
||||||
const report = parseReport(body);
|
const report = parseReport(body);
|
||||||
if (!report) return { recorded: false, reason: "unreadable" };
|
if (!report) {
|
||||||
if (!/^backup$/i.test(report.operation)) return { recorded: false, reason: "not_a_backup" };
|
const why = explainUnreadable(body);
|
||||||
|
await note({ outcome: "unreadable", operation: null, result: null, job: null, reason: why.reason, sample: why.sample });
|
||||||
|
return { recorded: false, reason: "unreadable" };
|
||||||
|
}
|
||||||
|
if (!/^backup$/i.test(report.operation)) {
|
||||||
|
await note({ outcome: "set_aside", operation: report.operation.slice(0, 60), result: report.result.slice(0, 30), job: report.backupName, reason: null, sample: null });
|
||||||
|
return { recorded: false, reason: "not_a_backup" };
|
||||||
|
}
|
||||||
|
await note({ outcome: "recorded", operation: "Backup", result: report.result.slice(0, 30), job: report.backupName, reason: null, sample: null });
|
||||||
|
|
||||||
const [before] = await db.select().from(duplicatiBackups).where(and(eq(duplicatiBackups.sourceId, source.id), eq(duplicatiBackups.name, report.backupName))).limit(1);
|
const [before] = await db.select().from(duplicatiBackups).where(and(eq(duplicatiBackups.sourceId, source.id), eq(duplicatiBackups.name, report.backupName))).limit(1);
|
||||||
const good = isGood(report.result);
|
const good = isGood(report.result);
|
||||||
@@ -293,6 +365,7 @@ export async function currentProblems(nowMs: number = Date.now()): Promise<Dupli
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** A source as lists show it: everything but the hash. */
|
/** A source as lists show it: everything but the hash. */
|
||||||
export function publicSource(row: SourceRow) {
|
export function publicSource(row: SourceRow, showSample = false) {
|
||||||
return { id: row.id, name: row.name, tokenPrefix: row.tokenPrefix, serverId: row.serverId, createdBy: row.createdBy, createdAt: row.createdAt, lastReportAt: row.lastReportAt };
|
const activity = unpackActivity(row.lastReport);
|
||||||
|
return { id: row.id, name: row.name, tokenPrefix: row.tokenPrefix, serverId: row.serverId, createdBy: row.createdBy, createdAt: row.createdAt, lastReportAt: row.lastReportAt, lastReport: activity && { ...activity, sample: showSample ? activity.sample : null } };
|
||||||
}
|
}
|
||||||
@@ -198,6 +198,79 @@ describe("where a backup stands, and what is an alert", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("what the last report was", () => {
|
||||||
|
test("why a body is not a report, in a sentence, with the start of it", () => {
|
||||||
|
assert.deepEqual(d.explainUnreadable(""), { reason: "the body was empty (or not text) — Duplicati should post its result as text or JSON", sample: null });
|
||||||
|
assert.equal(d.explainUnreadable(undefined).sample, null);
|
||||||
|
const cut = d.explainUnreadable('{"Data": {"MainOperation": "Backup"');
|
||||||
|
assert.match(cut.reason, /not valid JSON/);
|
||||||
|
assert.equal(cut.sample, '{"Data": {"MainOperation": "Backup"');
|
||||||
|
const noResult = d.explainUnreadable(JSON.stringify({ Data: { MainOperation: "Backup", Duration: "00:01:00" }, Extra: {} }));
|
||||||
|
assert.match(noResult.reason, /JSON without a ParsedResult field \(it has: MainOperation, Duration\)/);
|
||||||
|
assert.match(d.explainUnreadable("hello there").reason, /not JSON, and no "ParsedResult:" line/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the sample is the start of what was sent, never more than 600 characters", () => {
|
||||||
|
assert.equal(d.explainUnreadable("x".repeat(5000)).sample?.length, 600);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the counts grow by the kind of report, and the last one is what is shown", () => {
|
||||||
|
const a = d.nextActivity(null, "t1", { outcome: "set_aside", operation: "Compact", result: "Success", job: "Docs", reason: null, sample: null });
|
||||||
|
assert.deepEqual([a.outcome, a.counts], ["set_aside", { recorded: 0, setAside: 1, unreadable: 0 }]);
|
||||||
|
const b = d.nextActivity(a, "t2", { outcome: "unreadable", operation: null, result: null, job: null, reason: "x", sample: "y" });
|
||||||
|
const c = d.nextActivity(b, "t3", { outcome: "recorded", operation: "Backup", result: "Success", job: "Docs", reason: null, sample: null });
|
||||||
|
assert.deepEqual([c.at, c.outcome, c.counts], ["t3", "recorded", { recorded: 1, setAside: 1, unreadable: 1 }]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("what is stored is read back as it was, and junk in the column is none", () => {
|
||||||
|
const a = d.nextActivity(null, "t1", { outcome: "recorded", operation: "Backup", result: "Success", job: "Docs", reason: null, sample: null });
|
||||||
|
assert.deepEqual(d.unpackActivity(JSON.stringify(a)), a);
|
||||||
|
for (const junk of [null, "", "nope", "[]", "{}", '{"outcome":"recorded"}']) assert.equal(d.unpackActivity(junk), null, String(junk));
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("with reports that arrive", () => {
|
||||||
|
let token = "";
|
||||||
|
let id = 0;
|
||||||
|
before(async () => {
|
||||||
|
const made = await d.createSource({ name: "Quiet", serverId: null, createdBy: "Ada" });
|
||||||
|
token = made.token;
|
||||||
|
id = made.row.id;
|
||||||
|
});
|
||||||
|
const activity = async () => d.unpackActivity((await db.select().from(duplicatiSources).where(eq(duplicatiSources.id, id)))[0].lastReport);
|
||||||
|
|
||||||
|
test("before any report there is nothing to say", async () => {
|
||||||
|
assert.equal(await activity(), null);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a report about something other than a backup is said to be set aside, with what it was", async () => {
|
||||||
|
await d.recordReport(token, report({ MainOperation: "Compact", ParsedResult: "Success" }, "Docs"), new Date("2026-10-26T04:00:00Z"));
|
||||||
|
const a = (await activity())!;
|
||||||
|
assert.deepEqual([a.outcome, a.operation, a.result, a.job, a.counts], ["set_aside", "Compact", "Success", "Docs", { recorded: 0, setAside: 1, unreadable: 0 }]);
|
||||||
|
assert.equal((await db.select().from(duplicatiBackups).where(eq(duplicatiBackups.sourceId, id))).length, 0, "and no job was made");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a report that cannot be read says why, and keeps the start of it", async () => {
|
||||||
|
await d.recordReport(token, "this is not what Duplicati sends", new Date("2026-10-26T05:00:00Z"));
|
||||||
|
const a = (await activity())!;
|
||||||
|
assert.deepEqual([a.outcome, a.sample, a.counts.unreadable], ["unreadable", "this is not what Duplicati sends", 1]);
|
||||||
|
assert.match(a.reason ?? "", /ParsedResult/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a backup is said to be recorded, with the job and how it ended; the counts carry on; 'last heard' is the time of the last of any kind", async () => {
|
||||||
|
await d.recordReport(token, report({ ParsedResult: "Warning" }, "Docs"), new Date("2026-10-26T06:00:00Z"));
|
||||||
|
const a = (await activity())!;
|
||||||
|
assert.deepEqual([a.outcome, a.operation, a.result, a.job, a.counts], ["recorded", "Backup", "Warning", "Docs", { recorded: 1, setAside: 1, unreadable: 1 }]);
|
||||||
|
assert.equal((await db.select().from(duplicatiSources).where(eq(duplicatiSources.id, id)))[0].lastReportAt, "2026-10-26T06:00:00.000Z");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("an address nobody knows leaves nothing behind", async () => {
|
||||||
|
const before = await activity();
|
||||||
|
assert.deepEqual(await d.recordReport("hlm_d_not-a-real-token-at-all", report()), { recorded: false, reason: "unknown_token" });
|
||||||
|
assert.deepEqual(await activity(), before);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("what the warnings said", () => {
|
describe("what the warnings said", () => {
|
||||||
test("a report's warnings are kept as one line each, the first twenty, each cut at 500 characters; the first is the message", () => {
|
test("a report's warnings are kept as one line each, the first twenty, each cut at 500 characters; the first is the message", () => {
|
||||||
const r = d.parseReport(report({ ParsedResult: "Warning", WarningsActualLength: 3, Warnings: ["Failed to process path: C:\\locked.db\n access denied", " second ", { code: "x" }] }))!;
|
const r = d.parseReport(report({ ParsedResult: "Warning", WarningsActualLength: 3, Warnings: ["Failed to process path: C:\\locked.db\n access denied", " second ", { code: "x" }] }))!;
|
||||||
@@ -418,6 +491,20 @@ describe("the address Duplicati posts to, the pages, the alerts and /metrics", (
|
|||||||
who = "admin";
|
who = "admin";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("the page says what the last report was; only an administrator is given the start of one that could not be read", async () => {
|
||||||
|
await call("POST", `/duplicati-report/${token}`, "something that is not a report at all", { "content-type": "text/plain" });
|
||||||
|
const source = async () => ((await (await call("GET", "/duplicati")).json()) as any).sources[0];
|
||||||
|
who = "admin";
|
||||||
|
const asAdmin = await source();
|
||||||
|
assert.deepEqual([asAdmin.lastReport.outcome, asAdmin.lastReport.sample, asAdmin.lastReport.counts.unreadable >= 1], ["unreadable", "something that is not a report at all", true]);
|
||||||
|
for (const role of ["operator", "viewer"]) {
|
||||||
|
who = role;
|
||||||
|
const other = await source();
|
||||||
|
assert.deepEqual([other.lastReport.outcome, other.lastReport.sample, /ParsedResult/.test(other.lastReport.reason)], ["unreadable", null, true], role);
|
||||||
|
}
|
||||||
|
who = "admin";
|
||||||
|
});
|
||||||
|
|
||||||
test("a job set to alert on warnings raises one in the Backups kind, with the first message, and the page says what is wrong; switched off, it stops", async () => {
|
test("a job set to alert on warnings raises one in the Backups kind, with the first message, and the page says what is wrong; switched off, it stops", async () => {
|
||||||
invalidateAlertsCache();
|
invalidateAlertsCache();
|
||||||
const a = (await getAlerts(true)).alerts.find((x) => /^backup:duplicati-warnings:\d+:server:/.test(x.id))!;
|
const a = (await getAlerts(true)).alerts.find((x) => /^backup:duplicati-warnings:\d+:server:/.test(x.id))!;
|
||||||
|
|||||||
@@ -2091,6 +2091,18 @@ export interface DuplicatiSource {
|
|||||||
createdBy: string | null;
|
createdBy: string | null;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
lastReportAt: string | null;
|
lastReportAt: string | null;
|
||||||
|
/** What the last report turned out to be; null before any came (or from before this was kept). */
|
||||||
|
lastReport: {
|
||||||
|
at: string;
|
||||||
|
outcome: "recorded" | "set_aside" | "unreadable";
|
||||||
|
operation: string | null;
|
||||||
|
result: string | null;
|
||||||
|
job: string | null;
|
||||||
|
reason: string | null;
|
||||||
|
/** The start of what was sent, for an unreadable report; only administrators are given it. */
|
||||||
|
sample: string | null;
|
||||||
|
counts: { recorded: number; setAside: number; unreadable: number };
|
||||||
|
} | null;
|
||||||
backups: number;
|
backups: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { api, type CurrentUser, type DuplicatiBackup, type DuplicatiOverview, type DuplicatiRun } from "../api/client";
|
import { api, type CurrentUser, type DuplicatiBackup, type DuplicatiOverview, type DuplicatiRun, type DuplicatiSource } from "../api/client";
|
||||||
import CopyButton from "../components/CopyButton";
|
import CopyButton from "../components/CopyButton";
|
||||||
import DetailDrawer from "../components/DetailDrawer";
|
import DetailDrawer from "../components/DetailDrawer";
|
||||||
import EmptyState from "../components/EmptyState";
|
import EmptyState from "../components/EmptyState";
|
||||||
@@ -118,6 +118,43 @@ function History({ backup, onClose }: { backup: DuplicatiBackup; onClose: () =>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** What the last report on a machine's address was, and — when the machine has no jobs yet — why that may be. */
|
||||||
|
function Activity({ s }: { s: DuplicatiSource }) {
|
||||||
|
const a = s.lastReport;
|
||||||
|
if (!a) return null;
|
||||||
|
const c = a.counts;
|
||||||
|
const total = c.recorded + c.setAside + c.unreadable;
|
||||||
|
let line: string;
|
||||||
|
if (a.outcome === "recorded") line = `was a backup of “${a.job}”: ${a.result}`;
|
||||||
|
else if (a.outcome === "set_aside") line = `was ${a.operation ?? "something else"} — set aside, only a Backup makes a job here`;
|
||||||
|
else line = "could not be read";
|
||||||
|
const quiet = s.backups === 0;
|
||||||
|
return (
|
||||||
|
<div className="small mt-1">
|
||||||
|
<div className={a.outcome === "unreadable" ? "text-red" : "text-secondary"}>The last one {line}.</div>
|
||||||
|
{a.outcome === "unreadable" && a.reason && <div className="text-red">{a.reason}</div>}
|
||||||
|
<div className="text-secondary">
|
||||||
|
{total} so far: {c.recorded} backup{c.recorded === 1 ? "" : "s"}, {c.setAside} set aside, {c.unreadable} unreadable
|
||||||
|
</div>
|
||||||
|
{quiet && c.recorded === 0 && (
|
||||||
|
<div className="text-yellow">
|
||||||
|
{c.unreadable > 0
|
||||||
|
? "No job yet: what it sends could not be read."
|
||||||
|
: "No job yet: only reports of other operations have come. A job appears after its first Backup report — check that --send-http-level=All is set on that machine."}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{a.sample && (
|
||||||
|
<details>
|
||||||
|
<summary className="text-secondary">What was sent</summary>
|
||||||
|
<pre className="mb-0 small text-break" style={{ whiteSpace: "pre-wrap", maxHeight: 200, overflow: "auto" }}>
|
||||||
|
{a.sample}
|
||||||
|
</pre>
|
||||||
|
</details>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/** What to paste into Duplicati, shown once after a machine is added. */
|
/** What to paste into Duplicati, shown once after a machine is added. */
|
||||||
function Address({ path, name, onDone }: { path: string; name: string; onDone: () => void }) {
|
function Address({ path, name, onDone }: { path: string; name: string; onDone: () => void }) {
|
||||||
const url = `${window.location.origin}${path}`;
|
const url = `${window.location.origin}${path}`;
|
||||||
@@ -307,6 +344,7 @@ export default function Duplicati({ user }: { user: CurrentUser }) {
|
|||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<div className="small">{s.lastReportAt ? <>last heard <TimeAgo value={s.lastReportAt} /></> : <span className="text-secondary">nothing yet</span>}</div>
|
<div className="small">{s.lastReportAt ? <>last heard <TimeAgo value={s.lastReportAt} /></> : <span className="text-secondary">nothing yet</span>}</div>
|
||||||
|
<Activity s={s} />
|
||||||
</div>
|
</div>
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
<button className="btn btn-sm btn-outline-danger ms-auto" onClick={() => void removeSource(s.id, s.name)} aria-label={`Remove ${s.name}`}>
|
<button className="btn btn-sm btn-outline-danger ms-auto" onClick={() => void removeSource(s.id, s.name)} aria-label={`Remove ${s.name}`}>
|
||||||
|
|||||||
Reference in new issue
Block a user