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:
1 parent
12f2662465
commit
2f082ca5c2
23 files changed
+8047
-4
No files matched your search
@@ -1159,6 +1159,75 @@ export const haReadings = sqliteTable(
|
||||
(t) => [index("ha_readings_lookup_idx").on(t.integrationId, t.entityId, t.at)],
|
||||
);
|
||||
|
||||
// ─── Duplicati ──────────────────────────────────────────────────────────────
|
||||
|
||||
// A Duplicati that reports to this app: one row per machine running it, with the secret token its reports carry in their address (only the hash is kept). Duplicati pushes a
|
||||
// report after every operation (its own "send-http-url" option); services/duplicati.ts reads them.
|
||||
export const duplicatiSources = sqliteTable("duplicati_sources", {
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
name: text("name").notNull(),
|
||||
tokenHash: text("token_hash").notNull().unique(),
|
||||
tokenPrefix: text("token_prefix").notNull(),
|
||||
serverId: integer("server_id"), // soft reference: the server it runs on, so that server's maintenance silences its alerts
|
||||
createdBy: text("created_by"),
|
||||
createdAt: text("created_at")
|
||||
.notNull()
|
||||
.default(sql`(current_timestamp)`),
|
||||
lastReportAt: text("last_report_at"), // ISO
|
||||
});
|
||||
|
||||
// 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`.
|
||||
export const duplicatiBackups = sqliteTable(
|
||||
"duplicati_backups",
|
||||
{
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
sourceId: integer("source_id")
|
||||
.notNull()
|
||||
.references(() => duplicatiSources.id, { onDelete: "cascade" }),
|
||||
name: text("name").notNull(),
|
||||
lastReportAt: text("last_report_at"), // ISO
|
||||
lastResult: text("last_result"), // Success | Warning | Error | Fatal
|
||||
lastBegin: text("last_begin"),
|
||||
lastEnd: text("last_end"),
|
||||
durationSeconds: integer("duration_seconds"),
|
||||
examinedFiles: integer("examined_files"),
|
||||
sizeBytes: integer("size_bytes"), // what was examined: the size of the source
|
||||
addedFiles: integer("added_files"),
|
||||
modifiedFiles: integer("modified_files"),
|
||||
deletedFiles: integer("deleted_files"),
|
||||
warnings: integer("warnings").notNull().default(0),
|
||||
errors: integer("errors").notNull().default(0),
|
||||
message: text("message"), // the first error, or warning
|
||||
lastSuccessAt: text("last_success_at"), // ISO; a backup with warnings still counts
|
||||
consecutiveFailures: integer("consecutive_failures").notNull().default(0),
|
||||
expectedHours: integer("expected_hours").notNull().default(48),
|
||||
alert: integer("alert", { mode: "boolean" }).notNull().default(true),
|
||||
createdAt: text("created_at")
|
||||
.notNull()
|
||||
.default(sql`(current_timestamp)`),
|
||||
},
|
||||
(t) => [uniqueIndex("duplicati_backups_name_idx").on(t.sourceId, t.name)],
|
||||
);
|
||||
|
||||
// Each report of a backup, for its history: kept 400 days and at most 400 per job.
|
||||
export const duplicatiRuns = sqliteTable(
|
||||
"duplicati_runs",
|
||||
{
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
backupId: integer("backup_id")
|
||||
.notNull()
|
||||
.references(() => duplicatiBackups.id, { onDelete: "cascade" }),
|
||||
at: text("at").notNull(), // ISO
|
||||
result: text("result").notNull(),
|
||||
durationSeconds: integer("duration_seconds"),
|
||||
sizeBytes: integer("size_bytes"),
|
||||
filesChanged: integer("files_changed"),
|
||||
warnings: integer("warnings").notNull().default(0),
|
||||
errors: integer("errors").notNull().default(0),
|
||||
},
|
||||
(t) => [index("duplicati_runs_idx").on(t.backupId, t.at)],
|
||||
);
|
||||
|
||||
// ─── Service-level targets ──────────────────────────────────────────────────
|
||||
|
||||
// "99.9 % for Gitea": a target on an endpoint check, a server or an integration, measured over calendar months (services/serviceLevels.ts). The thing measured is a
|
||||
|
||||
Reference in new issue
Block a user