Backup and restore
Backing up the database and the vault as two separate operations, the encrypted archive format, and why you drill the restore before trusting it.
Two things hold an install’s state: the Postgres database and OpenBao’s own vault. They are backed up by two separate tools with two separate credentials, on purpose: a tool that could snapshot the whole vault as a side effect of a routine database backup would turn its own compromise into a full-vault leak. Take both on the same cadence; never let one tool hold both credentials.
What’s backed up
- Postgres: every service’s schema, by
cbctl assay backup/restore. - OpenBao’s raft state, including the Ed25519 signing key in Transit: by
bao operator raft snapshot, run separately with its own credential. - The unseal / recovery key shares: operator-held, off-host, never captured by any snapshot.
Taking a backup
export FORGE_BACKUP_KEY="$(bao kv get -field=value secret/assay/backup-key)"
cbctl assay backup --out ./backupsThis dumps the whole database and encrypts the dump as it streams: the plaintext never touches disk. The output is a .cbab archive plus a manifest (creation time, environment, edition, and a SHA-256 of the plaintext for integrity). The command then prints the paired OpenBao snapshot step; run it with a separate credential and move both files off-box.
pg_dump and pg_restore are not bundled in the distroless service image, so run backup and restore from an operator host with a postgresql-client matching the server’s major version. A mismatched client refuses against a newer server.
Restoring, and drilling
cbctl assay restore --archive ./backups/assay-<timestamp>.cbab --into <scratch-dsn>Restore is destructive to its target and refuses to run non-interactively without --yes. Always drill into a scratch database with --into first before trusting a backup; omitting it restores into production, which is only for a real recovery. The encryption format is tamper-evident: frames cannot be reordered, dropped, or spliced, and a truncated backup is detected as corrupt rather than silently restored as a partial database. After any real restore, run cbctl assay doctor: the audit log is hash-chained, and a restore replaces the whole chain from the backup point.