Repository navigation
backups: copy validated snapshots off the server, show backup health, and make setup insist on it - #91
Conversation
Automatic backups lived only in backups/ on the database's own disk. ADR 0023 amends ADR 0006: with --backup-copy-dir / CONSOLEBOOK_BACKUP_COPY_DIR, each validated snapshot is copied to a second disk or mounted share under a temporary name, fsynced, verified byte for byte by SHA-256, renamed into place, and pruned to the same retention. A failed copy never touches the local snapshot; it raises a backup_copy_failed notice to administrators and retries every 15 minutes, catching up whenever the copy directory lacks the newest snapshot. `backup --backup-copy-dir` copies a manual backup too. GET /api/backups/status (manage_users, enforced in backup_copy) reports backup health from the files themselves: the copy is current exactly when the newest local snapshot's name is in the copy directory. The administrator's home shows it with a warning until copies are current, the Getting started checklist gains that step, and guided setup shows it with the installer command that fixes it. install.sh takes --data-dir and --backup-dir, validates them before touching anything (absolute, copy outside data), keeps them in the env file, and writes a systemd drop-in so the sandbox may write exactly those paths; without a copy directory it ends with a warning. The release workflow proves the copy under the real sandbox. Refs #90 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
The copy proof waited five minutes and failed on aarch64 because the runner user cannot list /srv/consolebook-copies or the data directory's backups/: both are 0750 and owned by the service account, as intended. Inspect them with sudo. Refs #90 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
Brings #89's latest state (probe follows the bind, release workflow on every pull request, ADR 0023 for the installation lifecycle, and main through #92) into this branch. - release.yml: the upgrade step keeps both the backup warning check and the move to 127.0.0.2:7771. - The backup ADR becomes ADR 0024, since the installer ADR took 0023; every reference is renumbered, and ADR 0024 cites ADR 0023 for the unit's writable paths. - ADR 0023 now records --data-dir, --backup-dir, and the paths.conf drop-in this branch adds. Refs #90 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e2c602c134
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Review of #91 found three ways a copy could be reported current while it would not survive the server's disk: - The installer created a missing --backup-dir. On an unmounted share that put the copies on the local disk. The same happens at runtime when a share drops: its mount point is an empty local directory. Copies, retries, and the health read now refuse a copy directory on the local snapshots' filesystem and report it unreachable ("not mounted"). The installer never creates the directory and refuses a --backup-dir that is missing or on the data directory's filesystem; for an already-configured one it warns instead, so an upgrade is not blocked by a share that is down. - serve accepted the data directory itself as the copy directory; the filesystem rule covers that and any nesting. - A copy whose post-rename fsync failed kept its name and so counted as current and was never retried; it is now removed. Tests use /dev/shm as the second filesystem and add the unmounted case; stubbing the guard fails it. The release workflow mounts a tmpfs for the copy proof and checks that a plain local directory is refused while the service keeps running. ADR 0024 and the install guide state the rule. Refs #90 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1dc5ca07d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ata directory Rerunning the installer with a different --data-dir on an installation that has a database rewrote the only data-directory setting; the service then created an empty database there, the installer offered first-run setup, and every record seemed to have vanished. The installer now refuses that change before touching anything and says how to move the directory deliberately. A directory without a database can still be changed. The install guide documents the move, ADR 0023 records the rule, and the release workflow checks that the refusal changes nothing. Refs #90 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 36da1fb59a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
If pruning the copy directory failed after a copy was made and made durable, the retry found the newest copy in place and returned, so the prune was never retried and the share could grow past retention until a later snapshot happened to prune it. Catch-up now finishes retention when the newest copy is already there, after the same other-filesystem check. The catch-up test seeds an over-retention copy directory; removing the prune fails it. Refs #90 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba44ba2b0c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The generated drop-in granted the copy directory as a required
ReadWritePaths entry. systemd fails namespace setup for a missing
required path, so a share absent at boot or restart stopped the whole
service instead of leaving backups local and reporting the copy
location unreachable (ADR 0024: the application is never blocked by a
missing copy). The entry is now optional ("-"), like the base unit's.
The release workflow unmounts and removes the share after the copy
proof, restarts the service, and requires it to come up healthy.
Refs #90
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
The shell keeps a signed-in browser out of /login and /reset. Twelve browser steps clicked Sign out and navigated straight on; when the logout request was still in flight (a loaded CI runner), /reset bounced to the home page and the next fill waited out the test timeout. It failed pr-gate on #91 in drafts.spec.ts:113. One owning helper, signOut(page) in fixtures.ts, clicks Sign out and waits for /login, which the shell reaches only after the server ends the session. Every plain sign-out goes through it; the one deliberate exception tests that a failed save refuses sign-out. A scratch spec that delays the logout response by 1.5 s reproduced the bounce with the old pattern and passed with the helper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
|
The cause is a race in the browser tests. Twelve steps click Sign out and navigate on without waiting. When the logout is still in flight, the shell's guard bounces a signed-in browser from The fix is #102, a Generated by Claude Code |
Primary Issue
Closes #90
Problem And Outcome
Automatic backups (ADR 0006) lived only in
backups/on the database's own disk. A dead disk, ransomware, or a deleted data directory would take the records and every backup together. Nothing asked anyone to fix that, and nothing showed when backups ran.After this PR:
Changes
--data-dir,--backup-dir, and thepaths.confdrop-in.backup_copy.rs:copy_snapshotcopies to.partial, fsyncs, verifies the copy's SHA-256 against the snapshot, renames, and fsyncs the directory.catch_upcopies the newest snapshot when it is missing, or finishes retention when it is present.status/status_for(manage_users, enforced by the service): a copy is current exactly when the newest local snapshot's name is in a copy directory on another filesystem.backup_copy_failednotice.serveandbackupaccept--backup-copy-dir(CONSOLEBOOK_BACKUP_COPY_DIR), andservewarns at start when it is unset.GET /api/backups/status.BackupHealthpanel on the admin home, Getting started step 8, and a guided-setup Backups step.--data-dirand--backup-dirare validated before anything is stopped or replaced.paths.confgrants the chosen paths. The copy path is optional (-), so a missing share never stops the service.cmp-identical and journaled as verified;97d1488. It no-ops once test(e2e): wait for sign-out to finish before navigating #102 merges.Correction rung: 2 (mechanical). The copy and health contract has integration tests with negative controls. Stubbing the filesystem guard, the retention retry, or the "current" rule fails a test.
Scope
doctorinspecting the copy directory (backups: encrypt copies at rest and let doctor inspect the copy directory #99).Verification
97d1488, with the permission-bypass capabilities dropped and system Chromium:receipt.jsonsha2568f20468f62760474efbaace20567edcac0e39579df6286572a90dda202996840.tests/backup_copy.rs, 6/6./dev/shmis used as the second filesystem. Covered:97d1488:fmt-clippy-testpassed;releasepassed on both architectures with the refusal, copy, and missing-share-restart proofs above.97d1488.Review And Merge Notes
maininto docs: describe 0.1.0 in the roadmap and README #101 (docs), then tagv0.1.0.🤖 Generated with Claude Code
https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
Generated by Claude Code