How are backups taken, and how do we recover from disaster? #70
Notifications
Due Date
No due date set.
Depends on
Reference: bobby/hapi#70
Reference in new issue
Block a user
Part of #44
Question
What is the v1 backup and disaster-recovery plan: the off-platform
pg_dump(schedule, target, encryption, retention), the restore-to-new-cluster runbook (shared with plan resizes) and how often it's rehearsed, rebuilding the cluster from code, and what in-cluster state (e.g. the 1-year breakglass audit) needs its own backup?Context carried from the map: managed-DB backups and restore drills, cluster rebuild from code, in-cluster state. A restore forks a new DB cluster (new host), so rerun
hapi db bootstrapand repoint the app. Our own off-platformpg_dumpcovers account loss and >14-day retention (see ADR-0004). Resizing the DB plan uses the same restore-to-new-cluster runbook, so one rehearsal covers both. The backup target's credentials and the dump encryption key each follow ADR-0008 (one narrow token, delivered through SOPS). A cluster rebuild needs the age key from Vaultwarden or the offline copy. Thepg_dumpjob should report to a Kuma push monitor ("no successful backup in 26 h"), as ADR-0009 does with its Watchdog. The monitoring PVs hold only rebuildable or expendable data, except the 1-year breakglass audit events.From How do scheduled and background jobs run? (ADR-0012): recurring work runs as CronJobs of the hAPI image with
concurrencyPolicy: Forbid. Every CronJob is covered by a generic vmalert staleness rule, and Kuma push is reserved for jobs (like backups) whose silence must be caught even if the cluster is down. Apg_dumpCronJob uses connections from ADR-0004's amended budget.Resolution
Recorded in ADR-0014. It amends ADR-0004 (the
hapi_backuprole) and ADR-0009 (breakglass audit events now survive a rebuild).hapi db backupCronJob (hAPI image pluspostgresql-client-18), daily at 03:00 Household time. It streamspg_dump -Fc→pg_restore --listcheck → age → upload, and the plaintext never touches disk. It runs as a newhapi_backuprole (LOGIN,BYPASSRLS, SELECT only, created by bootstrap) using 1 connection.hapi-backupsin Linode Object Storage, with Object Lock in compliance mode, a 35-day lock and 35-day expiry. The cluster's key isread_write, limited to this bucket.infra/backup-pull/,rclone copy --immutable, with aread_onlykey. It keeps 90 dailies, monthlies for 3 years,audit/for 1 year, and also pulls the versioned Tofu state bucket. For now it runs on the Owner's PC as a systemd user timer (Persistent=true) and moves to a NAS later. It isn't a Principal.audit/.hapi db restorein a pod, with the private key pasted in at run time. Path (A) is a point-in-time fork; path (B) restores our dump into a new database. Both go through bootstrap and then repoint the app.akmadmincan create aBYPASSRLSrole on Aiven, and that a limitedread_writekey can't delete a locked version.