· docs
  1. Docs
  2. Guides

Backups and Upgrades

Nightly backups, pre-migration snapshots, where continuous replication fits, restoring, and upgrading safely.

#What Is Protected Automatically

MechanismWhenWhereKept
Nightly backupEvery night/data/backups/backup-<timestamp>.dbThe last 14
Pre-migration snapshotBefore any schema migration runs on an existing database/data/backups/pre-migration-v<N>-<time>.dbUntil you remove them
On demandSettings → General → Data & Backups (platform admin), or POST /api/backup/data/backups/With the nightly set

Backups are consistent SQLite online backups; the instance keeps running. Settings shows the time of the last backup.

Warning

Backups live on the same volume as the database. Copy them off the host, or use Litestream, so that losing the volume does not lose the backups.

#The Keys Directory

/data/keys holds the evidence-signing key pair, the session secret, and — if ARCHIGOV_SECRET_KEY is not set — the secret key that encrypts stored AI provider keys. It is never included in backups or Litestream replicas, by design. Back it up separately, to a secret store:

  • Losing the signing key means new evidence packs are signed by a new identity; old packs still verify against the old public key, which you should have recorded.
  • Losing the secret key means stored AI keys must be re-entered.
  • Losing the session secret signs everyone out.

#Continuous Replication with Litestream

Nightly backups sit on the same volume as the database and can be up to a day old. Litestream, included in the image, streams every change to object storage or another disk about once a second, restores automatically on a container whose volume is empty, and can recover to any moment in its retention period. Use it in production when losing the volume or the host must not lose data, and on any platform without persistent volumes.

Continuous replication with Litestream explains when you need it, how to set it up, how to check and test it, and how to recover to a point in time.

#Restoring from a Backup File

Shell
docker compose -f docker-compose.prod.yml stop archigov
# copy the chosen backup over the database, removing the WAL files
docker run --rm -v archigov_archigov-data:/data alpine sh -c \
  'cp /data/backups/backup-2026-10-14T02-00-00-000Z.db /data/app.db && rm -f /data/app.db-wal /data/app.db-shm'
docker compose -f docker-compose.prod.yml start archigov

The volume name depends on your compose project; check it with docker volume ls. After a restore, run GET /api/audit/verify — the chain must verify end to end.

#Upgrading

  1. Read the changelog for the target version.
  2. Take an on-demand backup and copy it off the host.
  3. Rebuild or pull the new image, and restart:
Shell
git pull && docker compose -f docker-compose.prod.yml up -d --build

On boot, pending migrations run in order, each after a pre-migration snapshot. Check /api/health and the version shown under Settings.

#Versions and Migrations

archigov follows semantic versioning. Migrations are forward-only: a release that needs a breaking schema change is a major version. To roll back, restore the pre-migration snapshot together with the previous image — never run an older image against a migrated database.