Repository navigation
Description
Problem
An instance restore checks the archive thoroughly before it changes anything (#439, #565). backup.js verify reads the whole archive: its manifest, its tag, its name, and every chunk to the end. That proves the right archive went in. Nothing checks what came out.
backup.sh restore runs pg_restore into shipkeep_restore, ends that database's sessions, then renames it into place. A pg_restore that exits 0 can still leave a database that does not match the archive:
- one that is empty, or that holds only part of the data;
- one whose schema is older or newer than the archive says.
The script cannot tell. It would swap that database in and report "Restored", and the previous database would survive only under shipkeep_before_restore_*.
The idea came from a reader's comment on the backup article: after a test restore, they check max(created_at) on a busy table and a row count, because they once had a restore that "worked" and produced an empty database.
Proposal
After pg_restore and before the rename, check the restored database against the manifest, which is authenticated:
- Schema: the newest applied migration in
_prisma_migrationsis the manifest'smigration. - Content: at least one user exists, since the installer creates the first account. When
audit_eventshas rows, its newestcreated_atis no later than the manifest'screatedAt, give or take clock skew. Every state change writes an audit event (CLAUDE.md, rule 6), so its newest row shows how recent the restored data is. - On failure:
- drop
shipkeep_restore, keep the current database, leave the key untouched; - say which check failed, with counts and timestamps only, never row contents;
- stop with the control plane stopped, as the other refusals at this step already do.
- drop
Acceptance criteria
- A restore whose
pg_restoreleaves an empty database is refused before the rename. The current database and the key file are unchanged. - A database restored without the manifest's newest migration is refused.
- A database whose newest audit event is later than the manifest's
createdAt(beyond the allowed skew) is refused. - A normal restore still succeeds, including the backup of an installation that holds only its first account.
- The refusal messages name the check and contain no data from the database.
-
docs/INSTALL.md("Back up and restore") and ADR 0026 describe the check.
Activity
docs: the README and the landing page describe v0.1.0-alpha.8 (#571)