DB backup script invoked before every schema or destructive DB operation #5
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Goal
Guardrail against losing the SQLite data file during development, tooling work, or manual recovery. A backup script must run before any operation that interacts with the database at the schema or destructive-data level.
Behavior
scripts/backup-db.sh [reason]copiesquartermaster.dbtobackups/quartermaster-YYYYMMDD-HHMMSS-{slug}.dbusingsqlite3 .backup(WAL-safe).QUARTERMASTER_DB_URLis set and starts withsqlite:///, that path is backed up instead.backups/is gitignored and kept forever (small dataset).env.pyinvokes the script before every offline or online migration run, tagged with reasonalembic.CLAUDE.mddocuments the rule so future sessions see it on load.Scope
Covers:
rm,truncate,DROP, etc) I or the user runs: the rule is "run the backup script first".Does not cover:
Acceptance criteria
./scripts/backup-db.shexists, is executable, and produces a timestamped file underbackups/usingsqlite3 .backupQUARTERMASTER_DB_URLwhen setenv.pyinvokes the script before migrations and does not fail the migration if the backup script itself errors out (the backup is defense in depth, not a hard prerequisite)backups/is in.gitignoreCLAUDE.mdstates the rule clearlyOut of scope