Skip to the content

Back up full Central and recover from a disaster

Back up full Central's Postgres, events and streams to another region, rehearse a restore, and bring the whole deployment back after losing it.

Built, not yet claimed preview: this guide describes a package that has not passed its release gate.

Full Central is built to lose at most 15 minutes of what it acknowledged and to be serving again within 4 hours after losing the whole deployment. That rests on three backups kept in another region, Postgres's archive, ClickHouse's event backups and a mirror of every event stream, and on the keys being available there too. You set them up, rehearse a restore, and follow the runbook when it counts.

1. Know what is backed up where

Postgres holds every tenant's configuration and audit chain: CloudNativePG archives its write-ahead log continuously, at least once a minute, beside a daily base backup, so it recovers to within a few minutes. ClickHouse's events are backed up hourly over a weekly full backup, each backup recording how far it reached in every event stream.

The event streams keep 72 hours and are mirrored to the recovery region, so a restore replays from the mirror whatever the newest event backup lacks. Keys are never in a backup: the tenants' keys are stored wrapped in Postgres, and the key that unwraps them stays with your KMS, HSM or the signer's bundle. Backups are kept 35 days.

2. Turn on the archive, the event backups and the mirror

For Postgres, install the Barman Cloud plugin (it needs cert-manager), then apply postgres-backups.yaml and the archive patch from the chart's examples, naming a bucket in another region. For the rest, add three blocks to the --full settings files: event_backups (the migration's, worker's and the operator's), dr_mirror (the migration's and the operator's), and erasure_journal (the migration's, every edge's and the operator's), each naming a ClickHouse named collection and a user of its own.

Give the journal's bucket Object Lock with a retention of at least 35 days: an erasure is written there first, so a restore can't bring an erased person's events back. Then operator backup now takes the first event backup and operator backup list shows it with each stream's mark.

helm install barman-cloud cnpg/plugin-barman-cloud --version 0.9.0 -n agentgarm-data -f barman-cloud.values.yaml
kubectl apply -f postgres-backups.yaml
garm-central --full operator.json operator backup now --full-backup
garm-central --full operator.json operator backup list

3. Keep the keys available in the recovery region

A restored Postgres is of no use without the key that unwraps the tenants' keys. With a cloud KMS or an HSM, replicate that key to the recovery region under the same custody. With software custody, keep a copy of each tenant's signer bundle and the operator host's state directories there, encrypted, apart from the backups. Keep the internal CA's key and every root ceremony's keys where the recovery team can reach them.

See also

Keep Central Lite's keys in a hardware security module

Create Central Lite's org with every key wrapped under a key that never leaves your PKCS#11 token, and keep what a restore needs backed up.

4. Rehearse a restore

operator restore events with --into restores the newest event backup into another, empty ClickHouse database and prints each stream's mark: a backup that restores there will restore in a disaster. Recover Postgres from its archive into a scratch cluster with postgres-recovery.yaml the same way.

Rehearse the whole runbook below in a staging deployment, timing each step, so the recovery time you report is one you measured.

garm-central --full operator.json operator restore events --into restore_check

5. Recover the deployment

Record the time, stop whatever is left of the old deployment, and in the recovery region install the operators. Recover Postgres from the archive to the newest write-ahead log with postgres-recovery.yaml. Then, from the operator host with the recovery region's --full file: operator restore events restores the newest event backup, operator restore begin puts every tenant in restore mode before any role serves, and operator restore replay brings back from the mirror every event the backup lacks.

operator restore check checks every ClickHouse table, and per tenant restore verify checks its audit chains and restore journal erases again whatever the restore brought back of an erased person. Then install the chart, pointed at the recovered stores and the replicated keys, and move each tenant's hostname to it.

garm-central --full operator.json operator restore events
garm-central --full operator.json operator restore begin --reason "region lost"
garm-central --full operator.json operator restore replay
garm-central --full operator.json operator restore check
garm-central --full operator.json --state-dir tenant restore verify
garm-central --full operator.json --state-dir tenant restore journal

6. Leave restore mode per tenant

In restore mode a tenant signs nothing its machines trust, so no machine is sent anything older than what it already holds. As machines reconnect, restore status lists each one as reported, and records per stream anything the recovery could not bring back.

Once no enrolled machine is silent, restore finish leaves restore mode; it is refused until the tenant's erasure journal was replayed. For a machine that will not come back, --allow-missing with a reason finishes without it. Machines then push from where the recovered Central left them, and the tenant is back.

garm-central --full operator.json --state-dir tenant restore status
garm-central --full operator.json --state-dir tenant restore finish

See also

Back up and restore Central Lite

Write Central Lite's encrypted backups by hand and on a schedule, and restore one so that no enrolled node refuses what Central Lite signs next.