diff --git a/scripts/postgres-backup.sh b/scripts/postgres-backup.sh index f70a04d..3f3d7a8 100755 --- a/scripts/postgres-backup.sh +++ b/scripts/postgres-backup.sh @@ -5,6 +5,9 @@ CREDENTIALS="-h ${PGHOST:-postgres} -U ${PGUSER:-postgres}" BACKUP_DIR=${BACKUP_DIR:-/backup} RETENTION_DAYS=${RETENTION_DAYS:-7} +# 自动创建备份目录 +mkdir -p "$BACKUP_DIR" + backup() { local filename="backup_$(date +%Y%m%d_%H%M%S).sql.gz" echo "[$(date +%Y-%m-%d\ %H:%M:%S)] Starting backup: $filename"