Skip to the content
Vaubaan Gateway
Docs menu

Backup and restore

A backup of an instance is two things kept apart: a consistent copy of its SQLite database, and the master key versions that copy is sealed under; the copy alone opens no credential, and the key alone is nothing.

Scheduled backup

With the backup.s3.* keys set (VAUBAAN_BACKUP_S3_*, examples in deploy/config/.env.example), the instance uploads a backup to an S3-compatible bucket on its own schedule (VAUBAAN_BACKUP_EVERY, VAUBAAN_BACKUP_AT, VAUBAAN_BACKUP_KEEP). Each one is encrypted under a key derived from the master key and restored into a temporary file before it leaves: a copy that fails that check is never uploaded. Settings → Administration → Encryption and GET /healthz report the latest one, the activity each run.

Make a copy

The image ships a command that copies the database with SQLite's VACUUM INTO, online, next to the original:

# Docker Compose (the service is named gateway in deploy/compose.yaml)
docker compose --env-file deploy/config/.env -f deploy/compose.yaml exec gateway node apps/gateway/backup.mjs

# Railway
railway ssh
vaubaan-entrypoint node /app/apps/gateway/backup.mjs

It prints what it made:

backup: /data/backup-2026-10-16T08-00-00-000Z.sqlite
backup: 1234567 bytes, schema version 15, integrity_check: ok
backup: its secrets are sealed under master key version(s) 1: …

It never overwrites a file, refuses to run as root (vaubaan-entrypoint drops to the image's user) and checks the copy. Copy the file off the volume, then delete it there. On Railway, for instance from your machine:

railway ssh -- base64 /data/<file> > backup.b64 && base64 -d backup.b64 > backup.sqlite
railway ssh -- rm /data/<file>

Check once on your setup that the copy opens with sqlite3 and passes PRAGMA integrity_check. A volume snapshot that captures the database and its -wal file together is also a valid backup; a plain copy of the database file without its -wal file is not.

Keep the key apart

Keep the master key outside the host and outside the backups. A copy opens only with the keys of the versions it names (the third line above), as they were when it was made: after a rotation, the copies taken before need the old key. Losing the key loses every stored credential.

Restore

A copy, made by hand or by the schedule, restores on an image at least as recent as the one that made it, with the master key of every version it names. Two ways:

  • A new instance starts from the copy. Set VAUBAAN_RESTORE_FROM (an absolute path or an https URL, kept as a secret) and VAUBAAN_RESTORE_SHA256, and start it on an empty volume. Before it opens the store, it checks the hash, SQLite's integrity, that the schema is not newer than the image and that its keys open every stored secret, then puts the copy in place; a refusal stops the start and writes nothing. Without the key file on the new host, the instance starts in setup mode: /admin/bootstrap asks for the bootstrap token and the key file the former instance handed out, then runs the same restore.
  • The command, gateway stopped: node apps/gateway/restore.mjs <file or https URL> --sha256 <hex> inside the container (with Compose, docker compose run --rm gateway node apps/gateway/restore.mjs …). --dry-run only checks; a store that exists is replaced only with --force, and kept aside as <name>.replaced-<time>.

Try it on a scratch instance before you need it. Moving an instance from host to host: move an instance.

More: the store handbook, Backup.

Last changed 2026-12-02. This page as Markdown: /docs/operations/backup-and-restore.md