fix: backup.sh数据库配置改为bossai@ubuntu,用unix socket连接
This commit is contained in:
@@ -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 <<EOF
|
||||
gunzip bossai_XXXXXXXX_XXXXXX.sql.gz
|
||||
# 恢复
|
||||
psql -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME < bossai_XXXXXXXX_XXXXXX.sql
|
||||
# 注意:在服务器上执行(ubuntu用户),本地无法连接数据库
|
||||
|
||||
EOF
|
||||
|
||||
|
||||
Reference in New Issue
Block a user