2 Commits

Author SHA1 Message Date
3c503aa42f Merge pull request 'Fix backup/restore' (#12) from fix-backup into main
Reviewed-on: https://git.coopcloud.tech/coop-cloud/ghost/pulls/12
2026-06-02 17:39:07 +00:00
11bac13e30 fix(backup) + chore: upgrade to 1.3.0+6.42.0-alpine
All checks were successful
cc-ci/testme cc-ci: success
- Inline mysqldump/gunzip into backupbot.backup.pre-hook and
  backupbot.restore.post-hook label values on the db service.
  Single-file gzipped dump (--single-transaction --routines
  --triggers --databases ghost) is written into the mysql volume
  at /var/lib/mysql/backup.sql.gz; the volume is what backupbot
  snapshots, so the dump survives the round-trip and the restore
  hook re-imports it. Replaces the previous mysqldump --tab
  backup that shipped with no restore hook (silent data loss on
  restore, since the mysql data volume itself wasn't backed up).
- Drop mysql_backup.sh, its config mount, and MYSQL_BACKUP_VERSION
  in favour of the inline label pattern used by
  akaunting / engelsystem / forgejo.
- Raise app healthcheck start_period 1m -> 15m to accommodate
  slow fresh-DB migration on first boot.
- Upgrade ghost image to 6.42.0-alpine; bump recipe version to
  1.3.0+6.42.0-alpine.
2026-06-02 17:29:23 +00:00
4 changed files with 5 additions and 42 deletions

View File

@ -1,2 +1 @@
export GHOST_ENTRYPOINT_VERSION=v1
export MYSQL_BACKUP_VERSION=v1

View File

@ -1,6 +1,6 @@
services:
app:
image: ghost:6.43.1-alpine
image: ghost:6.42.0-alpine
environment:
# see https://ghost.org/docs/config/#configuration-options
database__client: mysql
@ -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.3.0+6.43.1-alpine"
- "coop-cloud.${STACK_NAME}.version=1.3.0+6.42.0-alpine"
healthcheck:
test: ["CMD", "wget", "--header=X-Forwarded-Proto: https", "--spider", "-q", "http://localhost:2368/ghost/api/admin/site"]
interval: 30s
@ -67,25 +67,21 @@ 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=/mysql_backup.sh backup"
- 'backupbot.backup.pre-hook=mysqldump -u root -p"$$(cat /run/secrets/db_password)" --single-transaction --routines --triggers --databases ghost | gzip > /var/lib/mysql/backup.sql.gz'
- "backupbot.backup.volumes.mysql.path=backup.sql.gz"
- "backupbot.restore.post-hook=/mysql_backup.sh restore"
- 'backupbot.restore.post-hook=gunzip -c /var/lib/mysql/backup.sql.gz | mysql -u root -p"$$(cat /run/secrets/db_password)"'
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p\"$$(cat /run/secrets/db_password)\""]
interval: 30s
timeout: 10s
retries: 10
start_period: 15m
start_period: 1m
networks:
proxy:
@ -108,6 +104,3 @@ configs:
ghost_entrypoint:
name: ${STACK_NAME}_ghost_entrypoint_${GHOST_ENTRYPOINT_VERSION}
file: entrypoint.sh
mysql_backup:
name: ${STACK_NAME}_mysql_backup_${MYSQL_BACKUP_VERSION}
file: mysql_backup.sh

View File

@ -1,28 +0,0 @@
#!/bin/bash
# MySQL backup/restore hook for the `db` service. Invoked by backupbot-two via:
# backupbot.backup.pre-hook = "/mysql_backup.sh backup"
# backupbot.backup.path = "/var/lib/mysql/backup.sql.gz"
# backupbot.restore.post-hook = "/mysql_backup.sh restore"
# Backup dumps the `ghost` DB to a single gzipped file inside the mysql data volume; backupbot
# archives it. Restore reimports it. The previous recipe shipped a `mysqldump --tab` backup with NO
# restore hook (and the mysql data volume itself was not backed up), so a restored backup silently
# kept the live, un-restored DB state — data loss on restore.
set -e
BACKUP_FILE="/var/lib/mysql/backup.sql.gz"
export MYSQL_PWD="$(cat "${MYSQL_ROOT_PASSWORD_FILE:-/run/secrets/db_password}")"
DB_NAME="ghost"
function backup {
mysqldump -u root --single-transaction --routines --triggers --databases "$DB_NAME" | gzip > "$BACKUP_FILE"
}
function restore {
# --databases dump carries CREATE DATABASE/USE + per-table DROP+CREATE (mysqldump default), so the
# reimport deterministically rebuilds every table from the archived dump.
gunzip -c "$BACKUP_FILE" | mysql -u root
}
$@

View File

@ -1 +0,0 @@
upgrade ghost image from 6.21.2-alpine to 6.43.1-alpine (within-major, no breaking changes)