diff --git a/backup.sh b/backup.sh index ff582c8..42ab58c 100755 --- a/backup.sh +++ b/backup.sh @@ -16,9 +16,9 @@ set -euo pipefail BACKUP_DIR="${1:-./backups}" GPG_RECIPIENT="${2:-}" -DB_NAME="${DB_NAME:-mcp}" -DB_USER="${DB_USER:-postgres}" -DB_HOST="${DB_HOST:-localhost}" +DB_NAME="${DB_NAME:-bossai}" +DB_USER="${DB_USER:-ubuntu}" +DB_HOST="${DB_HOST:-/var/run/postgresql}" DB_PORT="${DB_PORT:-5432}" RETENTION_DAYS=7 @@ -30,7 +30,7 @@ COMPRESSED="$DUMP_FILE.gz" echo "[$(date)] 开始备份: $DB_NAME@$DB_HOST:$DB_PORT" -# 1. pg_dump 导出 +# 1. pg_dump 导出(通过 unix socket peer auth,无需密码) if pg_dump -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -f "$DUMP_FILE"; then echo "[$(date)] 导出成功: $DUMP_FILE" else @@ -71,6 +71,7 @@ cat <