diff --git a/compose.mariadb.yml b/compose.mariadb.yml index 7322938..2c20754 100644 --- a/compose.mariadb.yml +++ b/compose.mariadb.yml @@ -9,6 +9,11 @@ services: - GITEA_DB_USER=gitea db: image: "mariadb:10.11.2" + deploy: + labels: + backupbot.backup.pre-hook: 'mysqldump --single-transaction -u root -p"$$(cat /run/secrets/db_root_password)" gitea > /var/lib/mysql/backup.sql' + backupbot.backup.post-hook: "rm -rf /var/lib/mysql/backup.sql" + backupbot.backup.path: "/var/lib/mysql/backup.sql" command: | mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci environment: diff --git a/compose.postgres.yml b/compose.postgres.yml index f18ee1d..fcda6ac 100644 --- a/compose.postgres.yml +++ b/compose.postgres.yml @@ -9,6 +9,11 @@ services: - GITEA_DB_USER=gitea db: image: postgres:15.3 + deploy: + labels: + backupbot.backup.pre-hook: "PGPASSWORD=$$(cat $${POSTGRES_PASSWORD_FILE}) pg_dump -U $${POSTGRES_USER} $${POSTGRES_DB} > /var/lib/postgresql/data/backup.sql" + backupbot.backup.post-hook: "rm -r /var/lib/postgresql/data/backup.sql" + backupbot.backup.path: "/var/lib/postgresql/data" environment: - POSTGRES_DB=gitea - POSTGRES_USER=gitea diff --git a/compose.yml b/compose.yml index de68bf0..639552d 100644 --- a/compose.yml +++ b/compose.yml @@ -48,6 +48,7 @@ services: failure_action: rollback order: start-first labels: + - "backupbot.backup=true" - "traefik.enable=true" - "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)" - "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"