Skip to content

Commit 1ee649b

Browse files
author
root
committed
fix(deploy): use correct postgres user in upgrade script
1 parent f3b7321 commit 1ee649b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

deploy/upgrade_ldap_prod.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ mkdir -p "$BACKUP_DIR"
2828
# 备份数据库 (PostgreSQL 逻辑备份,最安全)
2929
echo " 正在导出 PostgreSQL 数据库..."
3030
if docker compose -f "$COMPOSE_FILE" ps | grep -q "postgres"; then
31-
docker exec sub2api-postgres pg_dump -U postgres sub2api > "$BACKUP_DIR/sub2api_db.sql" || echo "⚠️ 数据库导出可能不完整,请检查运行状态。"
31+
DB_USER=$(grep "POSTGRES_USER=" "$ENV_FILE" | cut -d'=' -f2)
32+
[ -z "$DB_USER" ] && DB_USER="sub2api"
33+
docker exec sub2api-postgres pg_dump -U "$DB_USER" sub2api > "$BACKUP_DIR/sub2api_db.sql" || echo "⚠️ 数据库导出可能不完整,请检查运行状态。"
3234
else
3335
echo "⚠️ PostgreSQL 容器未运行,跳过数据库逻辑备份。"
3436
fi

0 commit comments

Comments
 (0)