Commit 80b23dd2 by yiling.shen

Fix Docker container backup logic in deployment script

parent b8df6aab
Pipeline #3188 failed with stages
in 11 seconds
...@@ -90,7 +90,11 @@ else ...@@ -90,7 +90,11 @@ else
# 使用Docker容器备份 # 使用Docker容器备份
if docker ps | grep -q mysql; then if docker ps | grep -q mysql; then
log_info "使用Docker容器备份数据库..." log_info "使用Docker容器备份数据库..."
docker exec $(docker ps -q --filter "ancestor=mysql") \ # 查找MySQL容器
MYSQL_CONTAINER=$(docker ps -q --filter "ancestor=mysql" --filter "ancestor=mariadb" | head -1)
if [ -n "$MYSQL_CONTAINER" ]; then
log_info "找到MySQL容器: $MYSQL_CONTAINER"
docker exec "$MYSQL_CONTAINER" \
mysqldump -u"$DB_USER" -p"$DB_PASSWORD" \ mysqldump -u"$DB_USER" -p"$DB_PASSWORD" \
--single-transaction \ --single-transaction \
--routines \ --routines \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment