// PART 08
Backup and restore
Backups are only as good as their last verified restore. This page covers what to copy, the exact commands for each store, and the schedule that keeps both current.
What to back up
| Component | Data location | Priority | Method |
|---|---|---|---|
| PostgreSQL | botserver-stack/data/tables/ (prod container tables) |
Critical | pg_dump |
| Vault/OpenBao | botserver-stack/data/vault/ |
Critical | raft snapshot |
| OtterIO | botserver-stack/data/drive/ |
Critical | oc mirror |
| Configurations | botserver-stack/conf/ |
High | file copy (certificates separately, encrypted) |
| Bot packages | S3 buckets ({org}.gborg) |
High | oc mirror (covered by the drive mirror) |
| Models | botserver-stack/data/llm/ |
Medium | file copy (re-downloadable, checksummed) |
| Logs | botserver-stack/logs/ |
Low | optional |
There is no platform-wide encryption at rest for backups either: no TDE,
no SSE/KMS registration, no LUKS mapping in the shipped image. Encrypt
backups at the storage layer (gpg --symmetric before upload) when the
compliance posture requires it.
Database backup and restore
# Backup (custom format — faster restore, supports selective restore)
pg_dump -h localhost -U postgres -F c -f /tmp/backup.dump botserver
# Restore into a scratch database FIRST — never straight into the live one
createdb -U postgres botserver_restore
pg_restore -U postgres -d botserver_restore /tmp/backup.dump
# Verify the scratch copy (row counts, last migration, tenant probes), then:
sudo incus exec bot -- systemctl stop botserver
psql -h localhost -U postgres -c "ALTER DATABASE botserver RENAME TO botserver_broken;"
psql -h localhost -U postgres -c "ALTER DATABASE botserver_restore RENAME TO botserver;"
sudo incus exec bot -- systemctl start botserver
Point-in-time recovery: enable WAL archiving in postgresql.conf
(wal_level = replica, archive_mode = on, archive_command = 'cp %p /backup/wal/%f').
Vault backup
# Raft snapshot with the bundled OpenBao binary (needs a token that can read
# sys/storage/raft/snapshot — the root token from init.json works):
VAULT_ADDR=http://localhost:8200 VAULT_TOKEN=<token> botserver-stack/bin/vault/bao operator raft snapshot save vault-backup-$(date +%Y%m%d).snap
Keep conf/vault/init.json (unseal keys and root token) in a secure,
separate location. On Windows it is DPAPI-sealed to the user who runs the
stack — a file copy restored under another account cannot be unsealed; move
secrets with bao kv get instead.
Object storage backup
oc alias set local http://127.0.0.1:9100 "$DRIVE_ACCESSKEY" "$DRIVE_SECRET" --api s3v4
oc mirror local/ /backup/otterio/ # all buckets
oc mirror local/mybot.gbai /backup/bots/mybot.gbai/ # one bot
# Restore: oc mirror /backup/otterio/ local/ (stop affected bots first)
Never restore a whole drive over a live one while bots are writing.
Scheduling and verification
# crontab: daily DB at 02:00, weekly full on Sunday 03:00
0 2 * * * /opt/gbo/bin/backup-database.sh
0 3 * * 0 /opt/gbo/bin/full-backup.sh
Verify integrity with checksums (sha256sum + sha256sum -c) and — the part
that actually matters — rehearse the restore monthly with
scripts/restore_drill.sh (next page). Suggested retention: dailies 30 days,
weeklies 12 weeks, monthlies 12 months, and an annual archive when compliance
requires it.