fix: address review feedback for backup infrastructure
PR Checks / test-and-build (pull_request) Successful in 6m52s
PR Checks / test-and-build (pull_request) Successful in 6m52s
- compose.yaml: rewrite db-backup to use heredoc script instead of inline cron command, fixing date escaping and adding temp-file pipeline for reliable error detection - compose.yaml: fix pipefail issue by writing pg_dump to tmp file before compression and rotation - restore.sh: pass PGPASSWORD explicitly via docker compose exec -e - restore.sh: use ". .env" with set -a/+a instead of fragile xargs export Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+11
-1
@@ -35,7 +35,17 @@ services:
|
||||
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 -
|
||||
cat > /usr/local/bin/backup.sh << 'EOF'
|
||||
#!/bin/sh
|
||||
set -e
|
||||
TMPFILE="/tmp/backup_$$.sql"
|
||||
pg_dump -h db -U gmrelay -d gmrelay_db > "$TMPFILE"
|
||||
gzip "$TMPFILE"
|
||||
mv "$TMPFILE.gz" "/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
|
||||
EOF
|
||||
chmod +x /usr/local/bin/backup.sh
|
||||
echo "0 3 * * * /usr/local/bin/backup.sh" | crontab -
|
||||
crond -f
|
||||
|
||||
bot:
|
||||
|
||||
Reference in New Issue
Block a user