add backup labels for postgres and clickhouse

This commit is contained in:
p4u1
2023-11-09 11:16:49 +01:00
parent 7fa53d58eb
commit b72203b089
4 changed files with 51 additions and 1 deletions

View File

@ -45,18 +45,37 @@ services:
- POSTGRES_DB=plausible
networks:
- internal
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"
backupbot.restore.post-hook: sh -c 'gzip -d /postgres.dump.gz && pg_restore -U "$$POSTGRES_USER" --dbname="$$PLAUSIBLE_DB" < /postgres.dump && rm /postgres.dump'
plausible_events_db:
image: clickhouse/clickhouse-server:23.4.2.11-alpine
volumes:
- event-data:/var/lib/clickhouse
entrypoint: /custom-entrypoint.sh
configs:
- source: clickhouse-config
target: /etc/clickhouse-server/config.d/logging.xml
- source: clickhouse-user-config
target: /etc/clickhouse-server/users.d/clickhouse-user-config.xml
- source: clickhouse_entrypoint
target: /custom-entrypoint.sh
mode: 0555
networks:
- internal
deploy:
labels:
backupbot.backup: "true"
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.post-hook: clickhouse-backup restore events
backupbot.resoter.post-hook: "rm -rf /var/lib/clickhouse/backup/events"
volumes:
db-data:
@ -78,3 +97,6 @@ configs:
name: ${STACK_NAME}_db_entrypoint_${DB_ENTRYPOINT_VERSION}
file: entrypoint.postgres.sh.tmpl
template_driver: golang
clickhouse_entrypoint:
name: ${STACK_NAME}_clickhouse_entrypoint_${CLICKHOUSE_ENTRYPOINT_VERSION}
file: entrypoint.clickhouse.sh