WAL-safe DB backups + pre-migration snapshot (audit H4 baseline) #12
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/db-backups"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From
docs/audit-2026-06.mdH4. Branches offmain(independent). This is the same-volume baseline you approved; off-volume copies are a documented follow-up pending a destination.What it does
scripts/backup.mjs— WAL-safeVACUUM INTOsnapshot into<dataDir>/backups/(single consistent file, no-wal/-shm), timestamped, with retention (keep newestBACKUP_KEEP, default 14). Run viapnpm db:backupor importbackupDatabase().scripts/migrate.mjs— takes an automatic*-premigratesnapshot before applying migrations (Drizzles runtime migrator has no rollback). Warns-but-continues on backup failure so a transient issue cant crash-loop boot.package.jsondb:backupscript;.gitignoreignoresbackups/.Verified locally:
pnpm db:backupagainst dev.db produces a snapshot withPRAGMA integrity_check = okand correct row counts;migrate.mjsruns the pre-migration backup then migrates.pnpm typecheck/lint/test(40/40) pass.Still open (needs you): off-volume target — give me an object-storage/rsync destination and Ill wire snapshots to it. Also: set up the daily scheduled task in Dokploy (
node scripts/backup.mjs).