pg: backup, restore and pre-migration snapshot #106
Notifications
Due Date
No due date set.
Depends on
Reference: sam/archie#106
Reference in new issue
Block a user
Replace internal/store/maintenance.go file-based Backup/Restore/ValidateFile with pg_dump/pg_restore equivalents; take a snapshot before goose applies new migrations; keep the archied commands that expose them.
Notes
Folded into 7r0x.2 (2026-09-24): the recovery subcommands (backup, restore, validate, rollback in internal/app/archied/state_store_recovery.go) operate on the SQLite file and cannot survive the store moving, so they move with it: backup/restore via pg_dump/pg_restore, offline commands connect directly and take the ownership advisory lock.
2026-09-24 recon (.pi/pg-migrate-run/recon/05-import-and-removal.md): this needs a decision before it can be implemented, and it is not a port. SQLite VACUUM INTO has no in-process analogue; the candidates are pg_dump, pg_basebackup/PITR, or both. Atomic replace-by-rename is a file operation Postgres has no primitive for. The taskSchemaVersion/user_version 'newer than supported' refusal needs re-expressing against goose's version table. The ownership file lock stops being available as a single-writer invariant, because Postgres is inherently multi-client. Two shell consumers hard-depend on today's semantics and are not Go: scripts/archie-update-install refuses an install it cannot back up, and scripts/archie-update-watchdog rolls back via sqlite3 + cp. Decision is taken in archie-core-7r0x.9 (Wave 1); implementation lands with 7r0x.2. 7r0x.6 stays folded into 7r0x.2.
2ic ruling (approved): Snapshot/restore is the only database rollback; withdraw automatic goose Down/schema rollback because Down migrations that drop tables are data loss, not rollback. Snapshot the whole shared PostgreSQL database before migrations. Restore is an explicit offline operator action: stop every client, verify State Store serve-ownership advisory lock is available, then use pg_restore --clean. Document that restoring loses writes after the snapshot. Installer/watchdog must not imply an automatic schema rollback guarantee; retain fail-closed snapshot creation before update/migration.
2ic clarification: recovery must establish that all Archie serving processes are stopped, not merely the State Store. Check every service-specific lifetime ownership lock (including Gateway) before destructive restore; refuse if any is held or the check is incomplete.
Close reason
Closed
Imported from beads
archie-core-7r0x.6· GitHub #1017 · type task · priority P1 · created 2026-09-23 · closed 2026-09-28