feat(sv): Backups card — offsite DR status (Core-4 -> Farm) + /api/backups (2.6.0)

migration 026 backup_runs; POST ingest (owner) from offsite-backup.sh, GET for the
Sacred Valley card showing last run, per-guest sizes, Farm free, schedule.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-09 17:47:17 +10:00
parent 16e324102e
commit b967c0bfdd
10 changed files with 139 additions and 5 deletions

21
tests/api/backups.test.js Normal file
View File

@@ -0,0 +1,21 @@
import { describe, it, expect } from 'vitest';
import { ingest } from '../../lib/api/routes/backups.js';
describe('backups ingest schema', () => {
it('accepts a valid run', () => {
const r = ingest.safeParse({
ok: true, total_bytes: 2400000000, won_free_bytes: 33000000000,
guests: [{ vmid: 310, name: 'void-db', bytes: 518000000 }], duration_sec: 950
});
expect(r.success).toBe(true);
});
it('accepts an empty body (all fields optional)', () => {
expect(ingest.safeParse({}).success).toBe(true);
});
it('rejects negative bytes', () => {
expect(ingest.safeParse({ total_bytes: -5 }).success).toBe(false);
});
it('rejects malformed guests', () => {
expect(ingest.safeParse({ guests: [{ vmid: 1 }] }).success).toBe(false);
});
});