infra: add PostgreSQL daily backup via pg_dump with rotation
PR Checks / test-and-build (pull_request) Successful in 6m24s
PR Checks / test-and-build (pull_request) Successful in 6m24s
- Add db-backup service to compose.yaml (postgres:17-alpine + cron) - Add pgbackups volume for backup storage - Add scripts/restore.sh for manual restore from latest backup - Update .env.example with BACKUP_RETENTION_DAYS and BACKUP_VOLUME_NAME - Document backup/restore flow in README Bump version -> 1.15.0 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+26
-2
@@ -16,8 +16,30 @@ services:
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
|
||||
db-backup:
|
||||
image: postgres:17-alpine
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
POSTGRES_USER: gmrelay
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
||||
POSTGRES_DB: gmrelay_db
|
||||
PGPASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}
|
||||
BACKUP_RETENTION_DAYS: ${BACKUP_RETENTION_DAYS:-7}
|
||||
volumes:
|
||||
- pgbackups:/backups
|
||||
networks:
|
||||
- gmrelay
|
||||
entrypoint: ["sh", "-c"]
|
||||
command:
|
||||
- |
|
||||
echo "0 3 * * * pg_dump -h db -U gmrelay -d gmrelay_db | gzip > /backups/gmrelay_db_\$$(date +\%Y\%m\%d_\%H\%M\%S).sql.gz && find /backups -name 'gmrelay_db_*.sql.gz' -type f -mtime +\$${BACKUP_RETENTION_DAYS} -delete" | crontab -
|
||||
crond -f
|
||||
|
||||
bot:
|
||||
image: git.codeanddice.ru/toutsu/gmrelay-bot:1.14.0
|
||||
image: git.codeanddice.ru/toutsu/gmrelay-bot:1.15.0
|
||||
restart: always
|
||||
depends_on:
|
||||
db:
|
||||
@@ -30,7 +52,7 @@ services:
|
||||
- gmrelay
|
||||
|
||||
web:
|
||||
image: git.codeanddice.ru/toutsu/gmrelay-web:1.14.0
|
||||
image: git.codeanddice.ru/toutsu/gmrelay-web:1.15.0
|
||||
restart: always
|
||||
depends_on:
|
||||
db:
|
||||
@@ -52,6 +74,8 @@ volumes:
|
||||
name: ${POSTGRES_VOLUME_NAME:-game_pgdata}
|
||||
web_keys:
|
||||
name: ${WEB_KEYS_VOLUME_NAME:-gmrelay_web_keys}
|
||||
pgbackups:
|
||||
name: ${BACKUP_VOLUME_NAME:-game_pgbackups}
|
||||
|
||||
networks:
|
||||
gmrelay:
|
||||
|
||||
Reference in New Issue
Block a user