Work by a parallel session on 2026-09-12; committed here with the rest of the day's changes. Rationale in persistent-memory.d/2026-09-12-esh-vm-db-restic-repair.md. The only visible symptom was a systemd-failed unit from a Sep 6 repository network timeout after boot. The real fault was quieter and much worse: the pre-backup hook logged failures as WARN and returned zero, so pg_dumpall could fail every single night -- it used TCP localhost and wanted a password nobody supplied -- while restic dutifully backed up the stale April 23 dump still sitting in the staging directory and reported success. Mongo was fine, which is part of why it went unnoticed. Postgres now dumps over the /var/run/postgresql socket with peer auth and -w, and both database failures now fail the backup rather than masking it, while still preserving any prior per-DB dump rather than truncating to nothing. An ERRORS counter replaces the warn-and-continue path, and the staging directory is overridable via RESTIC_STAGE_DIR so the new test can exercise it. Adds backup.contract.md, retry.conf and test_pre_backup.py -- three red-green regression tests covering the failure modes above. systemd drop-ins on both jobs add network-online ordering plus Restart=on-failure with a 5m delay and a 3-per-hour limit, which addresses the original boot-timeout symptom. Verified against a real run: snapshot bc5eeaff at 07:01 PDT with a fresh 3.46MB PG dump, retrieved from the repository with decompression and completion marker checked (not a full restore). Repository check passed, 99 snapshots. The old hook and stale dump are preserved root-only at /var/lib/restic/repair-20260912.
1.1 KiB
esh-vm-db Restic repaired
User asked diagnose/fix two service issues. Only check was systemd-failed: Sep6 repository network timeout after boot. Backup exited0 nightly but pg_dumpall used TCP localhost, required a password, and silently kept April23 dump. Mongo dumps worked. Root cause was the WARN-only hook masking PG failure.
Fixed PG to /var/run/postgresql peer auth with -w, both DB failures now fail backup preserving prior per-DB dump. Three red-green regression tests pass. Added drop-ins to both jobs: network-online ordering, Restart=on-failure, RestartSec=5min, StartLimitIntervalSec=1h, StartLimitBurst=3.
Verified real backup bc5eeaff 07:01PDT; fresh PG gzip 3460215 bytes. Retrieved from repo, decompression and completion marker pass (not full restore). Check at07:02 passed 99 snapshots/10% data (19 packs). No failed units remain; both timers active, PG and Mongo active. Inactive/dead between jobs is normal. Old hook/dump preserved root-only /var/lib/restic/repair-20260912. Canonical configs/restic/esh-vm-db and playbooks/esh-vm-db-restic-repair.yaml. No DB restarts or auth-policy changes; changes saved locally, no commit.