8652425413
Move backup from a documented procedure to `deploy/backup.sh`: dumps Postgres (pg_dump --clean --if-exists, gzipped) and archives the MinIO /data directory into a single timestamped bundle under backups/. Reads config from the compose .env with the same defaults the stack uses; optional BACKUP_RETAIN_DAYS prunes old bundles (cron-friendly). BACKUP.md documents usage + the restore procedure (kept manual/documented rather than an untested destructive script). Closes #196 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Justin Paul <justin@jpaul.me>
1.8 KiB
1.8 KiB
Backup & restore
backup.sh produces a single bundle containing the Postgres database and the
MinIO object store. Run it from this deploy/ directory on the host that runs
the stack.
Back up
./backup.sh
# → backups/provenance-backup-20260609T140000Z.tar
The bundle contains:
db.sql.gz—pg_dump --clean --if-existsof the database, gzipped.minio-data.tar.gz— the MinIO/datadirectory (objects + bucket metadata).MANIFEST.txt— what's inside and when it was made.
Optional retention: BACKUP_RETAIN_DAYS=30 ./backup.sh also deletes bundles
older than 30 days. Schedule it from cron for off-box copies, e.g.:
15 3 * * * cd /path/to/provenance/deploy && BACKUP_RETAIN_DAYS=30 ./backup.sh
(Copy the resulting bundle off the host — a backup on the same disk isn't one.)
Restore
Restoring overwrites live data — stop the app first.
ts=20260609T140000Z # the bundle you're restoring
mkdir -p /tmp/restore && tar xf backups/provenance-backup-$ts.tar -C /tmp/restore
# 1. Database — the dump is --clean, so it drops & recreates objects.
docker compose stop backend worker
gunzip -c /tmp/restore/db.sql.gz \
| docker compose exec -T postgres psql -U "${POSTGRES_USER:-provenance}" -d "${POSTGRES_DB:-provenance}"
# 2. Objects — replace the MinIO data directory.
docker compose stop minio
docker compose run --rm --no-deps -T -v provenance_miniodata:/data minio \
sh -c 'rm -rf /data/* && tar xzf - -C /data' < /tmp/restore/minio-data.tar.gz
docker compose up -d
rm -rf /tmp/restore
Notes:
- The MinIO
/dataarchive is filesystem-level; restore into the same MinIO major version it was taken from. - Verify the volume name (
docker volume ls | grep miniodata) — compose prefixes it with the project name; adjust the-vmount accordingly.