fix(backup): single-file mysqldump backup + reimport-on-restore hook

The previous recipe backed the DB up as a mysqldump --tab into /var/lib/mysql-files with NO restore
hook (and the mysql data volume itself was not backupbot-labelled), so a restored backup silently
kept the live, un-restored DB state — data loss on restore. Add mysql_backup.sh (backup: gzipped
mysqldump --databases ghost into the data volume; restore: reimport it) wired via backupbot
backup.pre-hook + restore.post-hook, mirroring the postgres recipes (mattermost-lts, immich). Bump
1.2.0 -> 1.3.0.
This commit is contained in:
autonomic-bot
2026-05-30 04:58:53 +00:00
parent ff03db348f
commit a1e95fcbcd
3 changed files with 43 additions and 6 deletions

View File

@ -51,7 +51,7 @@ services:
- "traefik.http.middlewares.${STACK_NAME}-redirect.redirectscheme.permanent=true"
- "backupbot.backup=true"
- "backupbot.backup.path=/var/lib/ghost/content"
- "coop-cloud.${STACK_NAME}.version=1.2.0+6.21.2-alpine"
- "coop-cloud.${STACK_NAME}.version=1.3.0+6.21.2-alpine"
healthcheck:
test: ["CMD", "wget", "--header=X-Forwarded-Proto: https", "--spider", "-q", "http://localhost:2368/ghost/api/admin/site"]
interval: 30s
@ -67,14 +67,19 @@ services:
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_password
secrets:
- db_password
configs:
- source: mysql_backup
target: /mysql_backup.sh
mode: 0555
volumes:
- "mysql:/var/lib/mysql"
deploy:
labels:
- "backupbot.backup=true"
- "backupbot.backup.pre-hook=mysqldump -u root -p\"$$(cat /run/secrets/db_password)\" ghost --tab /var/lib/mysql-files/"
- "backupbot.backup.post-hook=rm -rf /var/lib/mysql-files/*"
- "backupbot.backup.path=/var/lib/mysql-files/"
- "backupbot.backup.pre-hook=/mysql_backup.sh backup"
- "backupbot.backup.post-hook=rm -f /var/lib/mysql/backup.sql.gz"
- "backupbot.backup.path=/var/lib/mysql/backup.sql.gz"
- "backupbot.restore.post-hook=/mysql_backup.sh restore"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p\"$$(cat /run/secrets/db_password)\""]
@ -103,4 +108,7 @@ secrets:
configs:
ghost_entrypoint:
name: ${STACK_NAME}_ghost_entrypoint_${GHOST_ENTRYPOINT_VERSION}
file: entrypoint.sh
file: entrypoint.sh
mysql_backup:
name: ${STACK_NAME}_mysql_backup_${MYSQL_BACKUP_VERSION}
file: mysql_backup.sh