ADR 003
Encrypted nightly backups, stored offsite
Context
Seven Postgres databases, the blog's content and uploaded family photos all live on one host. The hosting provider's snapshots sit with the same provider and account as the server itself, so they don't protect against account loss, ransomware or a bad docker volume rm. Some of the data is personal, so backups must stay unreadable wherever they are stored.
Options considered
| Option | For | Against |
|---|---|---|
| Provider snapshots only | One click | Same failure domain as the server; restores the whole disk, not one app |
| Object storage (S3, B2) with restic | Mature, deduplicated | Another vendor and account; a server compromise also leaks the storage credentials |
| Encrypt with an age public key, copy to a separate system | The server can encrypt but never decrypt; the offsite copy is pulled by a separate service that has no access to the server | Full copies rather than incremental; size grows with the data |
Decision
- At 02:30 IST a backup container runs
pg_dumpon every app database and archives the blog content and photo volumes (read-only mounts). It writes one file encrypted to an age public key and keeps 7 nights on the server. - At 03:15 a separate workflow downloads the already-encrypted file through a secret URL and stores it as a release in a private repository, keeping 14 nights. The credentials it uses can reach only that one repository.
- Any failure triggers a phone alert.
- The private key lives offline with the owner, so nothing running on the server can decrypt a backup.
Consequences
- Good: an attacker who gets the server gets ciphertext, not 14 days of history.
- Good: each app restores on its own from its own dump.
- Good: adding an app is one environment variable plus network access.
- Cost: if the offline key is lost, every backup is unreadable. This is the main operational risk, handled by keeping two offline copies.
- Known exclusions: the blog's MySQL (posts are exported through its API instead) and the workflow engine's database (workflows are exported as code).
- Not yet proven: no timed full restore drill. Until one has been run, recovery time is a guess. It's listed on the gaps page as the top priority.
Revisit when
- Data grows past a few GB a night. Then move to incremental backups with restic, still encrypted on the client.
- Any app needs a recovery point better than 24 hours. Then use WAL archiving for point-in-time recovery.
At bank scale
Set RPO and RTO per data class, approved by the business. Use continuous WAL archiving, immutable (WORM) storage in a second region, keys in an HSM or KMS with dual control, and quarterly restore tests whose evidence goes to audit. The core idea doesn't change: the system that writes backups must not be able to read or delete them.