fix(backup): reimport the postgres dump on restore (restore was a no-op)
All checks were successful
cc-ci/testme cc-ci: success

The recipe dumped the DB on backup but shipped NO backupbot.restore.post-hook, and
archived the whole live PGDATA dir — so a restore extracted files under the running
postgres without reloading them, silently keeping the un-restored (live) state. A
restored backup therefore lost all data written since the snapshot.

Switch to the coop-cloud /pg_backup.sh convention (as matrix-synapse): backup =
pg_dump|gzip -> backup.sql; restore = terminate connections, FORCE-drop, recreate,
reimport the dump deterministically. Archive just backup.sql, not the whole PGDATA dir.
This commit is contained in:
autonomic-bot
2026-05-30 00:38:44 +00:00
parent 41c9eb8e5f
commit 4ca7f4182d
3 changed files with 44 additions and 3 deletions

View File

@ -58,9 +58,13 @@ services:
deploy:
labels:
backupbot.backup: "true"
backupbot.backup.pre-hook: "PGPASSWORD=$$(cat $${POSTGRES_PASSWORD_FILE}) pg_dump -U $${POSTGRES_USER} $${POSTGRES_DB} > /var/lib/postgresql/data/postgres-backup.sql"
backupbot.backup.post-hook: "rm -rf /var/lib/postgresql/data/postgres-backup.sql"
backupbot.backup.path: "/var/lib/postgresql/data/"
backupbot.backup.pre-hook: "/pg_backup.sh backup"
backupbot.backup.volumes.postgres_data.path: "backup.sql"
backupbot.restore.post-hook: "/pg_backup.sh restore"
configs:
- source: pg_backup
target: /pg_backup.sh
mode: 0555
secrets:
@ -69,6 +73,9 @@ secrets:
name: ${STACK_NAME}_postgres_password_${SECRET_POSTGRES_PASSWORD_VERSION}
configs:
pg_backup:
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
file: pg_backup.sh
abra_mattermost_entrypoint:
name: ${STACK_NAME}_entrypoint_${ABRA_MATTERMOST_ENTRYPOINT_VERSION}
file: ./entrypoint.sh