Skip to content

Backups

The Compose stack includes a backup service. It runs from the first docker compose up -d with no configuration.

Every BACKUP_INTERVAL seconds it writes a compressed pg_dump into the backups volume as app-<timestamp>.dump, then deletes everything past the newest BACKUP_KEEP files.

Variable Default Meaning
BACKUP_INTERVAL 86400 Seconds between dumps. The default is daily.
BACKUP_KEEP 7 Dumps retained.

So the default is a week of daily snapshots. To keep a month of them:

BACKUP_KEEP=30

A backup on the same disk as the database is not a backup. The volume is on thehost. Find it and sync it somewhere else:

docker volume inspect conatus_backups --format '{{ .Mountpoint }}'

Or copy the newest dump out on demand:

docker compose cp backup:/backups ./backups
docker compose exec db pg_dump -U app -Fc app > backup.dump

Do this before every upgrade. See Upgrading.

docker compose exec -T db pg_restore -U app -d app --clean --if-exists < /path/to/app-<timestamp>.dump

--clean --if-exists drops the existing objects first, so this replaces the current database contents. Stop the app before restoring so nothing writes into a half-restored schema:

docker compose stop app
docker compose exec -T db pg_restore -U app -d app --clean --if-exists < backup.dump
docker compose start app

If you restore a dump taken from an older release, start the stack normally. afterwards. The migrate job runs before the app and brings the schema forward.

An untested backup is a guess. Once, on a throwaway copy of the stack, restore your newest dump and log in. It takes ten minutes and it is the only thing that tells you the dumps are real.