feat(supabase): db:trial backup, restore, destroy, migrate, rotations
Cold read-only backups proven before any change (checksums covering the folder, entry counts, keys, images); typed confirmations at a terminal only; rotate-secrets in one explicit transaction with a commit marker, no secrets.prev; destroy refuses without a restorable backup and names the manual way out. Harness: 210 stub-only cases.
This commit is contained in:
1 parent
1a7b952f2f
commit
b85614aa09
3 files changed
+994
-11
No files matched your search
@@ -3016,6 +3016,25 @@ fresh_log; trial_tty faunosteo_trial destroy
|
||||
check "destroy with no resource: after the phrase, the live files go, backups and marker kept, no Docker removal" bash -c '[ "$1" -eq 0 ] && [ ! -e "$2/secrets.env" ] && [ ! -e "$2/db.env" ] && [ -d "$2/backups" ] && [ -e "$2/.faunosteo-trial-state" ] && ! grep -qE "^docker (rm|volume rm|network rm) " "$3"' _ "$RC" "$STATE_DIR" "$CASE/log"
|
||||
```
|
||||
|
||||
#### Lot B2 review fixes (2026-11-10)
|
||||
|
||||
- Backup proof: `verify_backup_integrity` (no symlinked `backups/` or folder, no non-regular entry, SHA256SUMS lists exactly the folder's files, checksums, every tar lists) and `check_backup` (integrity, the four required files, parse, keys signed by its own secret, all six recorded images present). `refuse_backup` takes the caller's outcome sentence, so a check after a backup never says "nothing was changed".
|
||||
- Uses: restore (`check_backup` before the confirm, `verify_backup_integrity` again right before the extraction loop); migrate, rotate-keys, rotate-secrets and destroy (`check_backup` right after their backup, before any change or removal; destroy stays stopped and names the kept backup); restore's pre-restore backup (`check_pre_restore_backup`: integrity mandatory, a note, no stop, when `check_backup` would refuse it).
|
||||
- Restore: `restore_stopped` EXIT trap (set after the pre-restore backup, cleared at the end) names the pre-restore backup and the rerun, or says none was taken; state files come back through `write_private` (600).
|
||||
- Restore refuses a symlinked `backups/` or backup folder; `new_backup_dir` refuses a symlinked `backups/`.
|
||||
- rotate-secrets: `ROTATION_COMMITTED=yes` only after `mv -f` of secrets.next.env; the "not committed" message now says secrets.env did not take the new secrets (true in the commit-to-rename window). A leftover secrets.next.env is refused before the key check and any backup; `status_leftover_rotation` prints one line, never the content.
|
||||
- Rotation SQL: explicit `begin;` ... `commit;` (no `--single-transaction`, which would commit a truncated script), session named `PGAPPNAME=db-trial-rotate`; `settle_rotation` first waits (`wait_rotation_session_gone`, `ROTATION_WAIT_POLLS` = 10, one poll a second) for that session to end, else `rotation_unknown`.
|
||||
- Lock first: backup, migrate, rotate-keys, rotate-secrets call `require_state; take_lock` before `require_created` / `require_running`.
|
||||
- Destroy: the content inventory cannot stop it (`(content unreadable)`). backup_now: refuses a leftover helper container before any stop; `backup_interrupted` EXIT trap (cleared on success and by `backup_failed`) names the incomplete folder; its guard on `$?` is dropped because a SIGTERM leaves 0 in it.
|
||||
- Harness H5 "B2 review fixes": one case per fix plus the spec gaps; stub hooks `image-nondb`, `extract`, `term-in-archive`, `append-on-rm`, `answers/measure-kib`, `answers/<tag>.seq`; `bin-mvfail` PATH for the commit-to-rename window. Two earlier assertions changed: the psql argv now carries `-e PGAPPNAME`; the stop-then-helper-then-start order matches the helper `docker run` line (the leftover-helper inspect now logs the name earlier).
|
||||
- Destroy dead end: when its pre-destroy backup cannot be made (`backup_failed` appends `BACKUP_WAY_OUT`, set by destroy only) or fails `check_backup`, destroy still refuses and removes nothing, and `destroy_way_out` ends the message with the backup kept (or none), the exact `docker rm` / `docker network rm` / `docker volume rm` lines for what exists, then `pnpm db:trial destroy`; the script never runs them. `create_stopped`'s hint says so.
|
||||
- `rotation_stopped` picks its branch from the state (secrets.next.env gone means the rename happened), and its trap is armed only after secrets.next.env exists and parses; `settle_rotation` clears the trap before removing the file. `keys_stopped` is armed after the `mv -f` of secrets.env.
|
||||
- Restore: `restore_stopped` armed after `ports_free` (a refusal there prints no half-filled message); a leftover helper container is refused before the confirmation.
|
||||
- `destroy_stopped` EXIT trap, armed once the pre-destroy backup passed `check_backup`, cleared on success: names that backup and what may remain.
|
||||
- A leftover secrets.next.env is in `BACKUP_FILES`, copied by `backup_now`, brought back by restore (`write_private`, 600; status flags it), noted by `check_pre_restore_backup`; the exact-listing rule of `verify_backup_integrity` already accepts it (it compares the folder to its own SHA256SUMS).
|
||||
- `backup_interrupted` says "the stack may be stopped". `check_backup` keeps `2>/dev/null` on the two parses: `parse_secrets` and `parse_conf` print nothing, so there is no reason to show.
|
||||
- Harness: one case per fix (stub PATH `bin-mvterm` for a SIGTERM on a rename). Changed assertions: the trial-port restore refusal asserts no "half-filled" message instead of the pre-restore backup name; the backup-interruption case asserts the new wording.
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user