初始化

This commit is contained in:
2026-06-25 13:34:41 +08:00
parent b53df728ce
commit 635248ece7
4 changed files with 13 additions and 84 deletions
+13 -5
View File
@@ -28,7 +28,6 @@ services:
- ../data/postgres:/var/lib/postgresql/data
- ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql
- ./sql/init-replication.sql:/docker-entrypoint-initdb.d/init-replication.sql
- ./sql/init-pg-hba.sh:/docker-entrypoint-initdb.d/init-pg-hba.sh
command: ["postgres", "-c", "wal_level=replica", "-c", "max_wal_senders=10", "-c", "max_replication_slots=10", "-c", "hot_standby=on"]
networks:
- redfuture-net
@@ -48,7 +47,6 @@ services:
condition: service_healthy
volumes:
- /data/pgsql/backup:/backup
- ./scripts/postgres-backup.sh:/usr/local/bin/backup.sh
environment:
PGUSER: postgres
PGPASSWORD: Bjang09@686^*^
@@ -56,9 +54,19 @@ services:
PGPORT: 5432
BACKUP_DIR: /backup
RETENTION_DAYS: 7
command: sh /usr/local/bin/backup.sh
networks:
- redfuture-net
entrypoint: ["/bin/sh", "-c"]
command:
- |
set -e
mkdir -p "/backup"
while true; do
f="backup_$(date +%Y%m%d_%H%M%S).sql.gz"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting backup: $${f}"
pg_dumpall -h postgres -U postgres | gzip > "/backup/$${f}"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Backup complete"
find /backup -name "backup_*.sql.gz" -mtime +7 -delete 2>/dev/null || true
sleep 86400
done
# ---- Redis ----
redis: