Repository navigation
Description
Problem
Automatic backups (ADR 0006) take a validated VACUUM INTO snapshot on schedule and keep 14, but always in backups/ on the same disk as the database. A failed disk, ransomware, or an accidental deletion of the data directory loses the records and every backup together. Nothing in the product asks an administrator to put a copy anywhere else. Nothing shows when backups last ran, and the installer gives no choice of where data or backups live. For training records with retention obligations, an off-server copy should be the expected state, not an operator's afterthought.
Outcome
-
An optional backup copy directory (
--backup-copy-dir/CONSOLEBOOK_BACKUP_COPY_DIR; a second disk or a mounted network share). After each validated local snapshot,serveandbackupcopy it there:- write to a temporary name, fsync, and validate the copy by opening it;
- then rename into place, fsync the directory, and prune to the same retention.
A failed copy never removes or weakens the local snapshot. It is reported like a failed backup, as an administrator notice.
-
Backup health, derived from the files themselves (
GET /api/backups/status,manage_users): the interval and retention, the local snapshot count and newest time, and whether a copy directory is configured, reachable, and current (its newest copy is no older than the newest local snapshot). -
The admin home shows backup health. A warning stays visible while no off-server copy is configured or the copy has fallen behind. The Getting started checklist gains a step that is done only when copies are current. The guided setup gets a Backups step that shows status and the exact installer command to fix it, since the service cannot and should not rewrite its own configuration.
-
The installer takes
--data-dirand--backup-dir. It writes them into the env file and a systemd drop-in, so the sandbox can write only those paths. Without--backup-dir, it ends with a prominent warning. -
An ADR amends ADR 0006 with the copy contract, and
docs/install.mdgains a backup section.
Scope
- Out of scope:
- Encryption of backups at rest (ADR 0006 already defers it).
- Push-to-cloud transports: mount the target instead.
- Restore from the copy directory beyond the existing
restore <snapshot>path, which already accepts any path. - Hard-blocking use of the application without a copy.
Acceptance
- Integration tests:
- a configured copy directory receives a validated copy and is pruned to retention;
- an unwritable copy directory fails the copy, keeps the local snapshot, and notifies administrators (negative control);
- status reports current, behind, and unconfigured correctly.
- ADR accepted.
- A browser test shows the home warning without a copy directory.
- The installer passes shellcheck;
--data-dirand--backup-dirare exercised locally (--no-service), and on systemd in the release workflow. - Full required gates and hosted
pr-gatepass.
Refs #87. Authorization: the maintainer's request in the working session ("some sort of backup mechanism should be strongly encouraged if not required"), with standing permission to carry it through merge and cleanup.
Activity
ci(release): inspect the service's directories as root
Merge the installer branch into off-server backups
fix(backups): never use or count a copy directory on the local disk
fix(install): refuse to point an installation with records at a new d…
fix(backups): finish copy-directory retention on the next retry
fix(install): let the service start when its backup share is missing