diff --git a/compose.yml b/compose.yml index 037d79e..d8cb158 100644 --- a/compose.yml +++ b/compose.yml @@ -54,11 +54,15 @@ services: deploy: labels: backupbot.backup: "true" - backupbot.backup.pre-hook: sh -c 'pg_dump -U "$$POSTGRES_USER" -Fc "$$POSTGRES_DB" | gzip > "/postgres.dump.gz"' - backupbot.backup.path: "/postgres.dump.gz" - backupbot.backup.post-hook: "rm -f /postgres.dump.gz" + # backup-bot-two v2 snapshots paths INSIDE named volumes (backupbot.backup.volumes..path, + # relative to the volume root) and ignores the old `backupbot.backup.path` label — a dump + # written to the container root fs never reaches the snapshot, so restore finds nothing. + # The dump therefore lives (transiently — the hooks remove it) at the db-data volume root. + backupbot.backup.volumes.db-data.path: "postgres.dump.gz" + backupbot.backup.pre-hook: sh -c 'pg_dump -U "$$POSTGRES_USER" -Fc "$$POSTGRES_DB" | gzip > /var/lib/postgresql/data/postgres.dump.gz' + backupbot.backup.post-hook: "rm -f /var/lib/postgresql/data/postgres.dump.gz" backupbot.restore: "true" - backupbot.restore.post-hook: sh -c 'gzip -d /postgres.dump.gz && pg_restore --clean -U "$$POSTGRES_USER" --dbname="$$PLAUSIBLE_DB" < /postgres.dump && rm -f /postgres.dump' + backupbot.restore.post-hook: sh -c 'gzip -d /var/lib/postgresql/data/postgres.dump.gz && pg_restore --clean -U "$$POSTGRES_USER" --dbname="$$POSTGRES_DB" < /var/lib/postgresql/data/postgres.dump && rm -f /var/lib/postgresql/data/postgres.dump' plausible_events_db: image: clickhouse/clickhouse-server:23.4.2.11-alpine @@ -78,8 +82,11 @@ services: deploy: labels: backupbot.backup: "true" + # v2 volumes-include syntax (see db service): snapshot only the clickhouse-backup output + # inside the event-data volume — not the live raw data files (restoring those under a + # running server is unsafe; the restore post-hook performs the logical restore instead). + backupbot.backup.volumes.event-data.path: "backup/events" backupbot.backup.pre-hook: clickhouse-backup create events - backupbot.backup.path: "/var/lib/clickhouse/backup/events" backupbot.backup.post-hook: "rm -rf /var/lib/clickhouse/backup/events" backupbot.restore: "true" backupbot.restore.post-hook: clickhouse-backup restore --rm events && rm -rf /var/lib/clickhouse/backup/events