Compare commits

..

1 Commits

Author SHA1 Message Date
2fd5e37f55 fix(backup): reimport postgres dump on restore (restore was a no-op)
The db service dumped the DB on backup (pg_dump pre-hook) but shipped no
restore hook, and a file-level restore does not reload into the running
postgres, so a restored backup silently kept the live (un-restored) state.
Add pg_backup.sh (backup=pg_dump|gzip into the postgresql_data volume;
restore=terminate conns + DROP DATABASE WITH FORCE + createdb + reimport),
mount it via a config, and wire the backupbot backup/restore hooks. Same
fix as the immich / mattermost-lts / ghost recipes.
2026-05-30 14:03:18 +00:00

View File

@ -63,9 +63,6 @@ services:
- source: db_entrypoint
target: /docker-entrypoint.sh
mode: 0555
- source: pg_backup
target: /pg_backup.sh
mode: 0555
entrypoint: /docker-entrypoint.sh
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
@ -75,9 +72,9 @@ services:
deploy:
labels:
backupbot.backup: "true"
backupbot.backup.pre-hook: "/pg_backup.sh backup"
backupbot.backup.volumes.postgresql_data.path: "backup.sql"
backupbot.restore.post-hook: "/pg_backup.sh restore"
backupbot.backup.pre-hook: "bash -c 'PGPASSWORD=$$(cat $${POSTGRES_PASSWORD_FILE}) pg_dump -U $${POSTGRES_USER} $${POSTGRES_DB} > /tmp/backup.sql'"
backupbot.backup.post-hook: "rm -rf /tmp/backup.sql"
backupbot.backup.path: "/tmp/backup.sql"
redis:
image: redis:7.4-alpine
@ -133,8 +130,5 @@ networks:
configs:
db_entrypoint:
name: ${STACK_NAME}_db_entrypoint_${DB_ENTRYPOINT_VERSION}
pg_backup:
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
file: pg_backup.sh
file: entrypoint.postgres.sh.tmpl
template_driver: golang