mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-09 08:20:31 +08:00
fix: filter GTID_PURGED from SQL imports to avoid MySQL error 1840
Former-commit-id: 3d9d223cdb274faf74d5ee138dd76608415b77e5
This commit is contained in:
@@ -42,8 +42,8 @@ for db_name in "${!DB_MAP[@]}"; do
|
|||||||
# Create DB if not exists
|
# Create DB if not exists
|
||||||
$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS \`$db_name\` DEFAULT CHARACTER SET utf8mb4;"
|
$MYSQL_CMD -e "CREATE DATABASE IF NOT EXISTS \`$db_name\` DEFAULT CHARACTER SET utf8mb4;"
|
||||||
|
|
||||||
# Import
|
# Import (strip GTID_PURGED to avoid error 1840 on non-empty GTID_EXECUTED)
|
||||||
zcat "$backup_path" | $MYSQL_CMD "$db_name" 2>&1 | tail -1
|
zcat "$backup_path" | sed '/GTID_PURGED/d' | $MYSQL_CMD "$db_name" 2>&1 | tail -1
|
||||||
|
|
||||||
if [[ ${PIPESTATUS[0]} -eq 0 ]]; then
|
if [[ ${PIPESTATUS[0]} -eq 0 ]]; then
|
||||||
log_ok " $db_name restored successfully"
|
log_ok " $db_name restored successfully"
|
||||||
@@ -55,7 +55,7 @@ done
|
|||||||
# Elevator app also needs second backup (34_*.sql.gz)
|
# Elevator app also needs second backup (34_*.sql.gz)
|
||||||
if [[ -f "$DATA_BACKUP/34_2026_04_23_17_28_33.sql.gz" ]]; then
|
if [[ -f "$DATA_BACKUP/34_2026_04_23_17_28_33.sql.gz" ]]; then
|
||||||
log_info "Restoring elevator DB partition 34..."
|
log_info "Restoring elevator DB partition 34..."
|
||||||
zcat "$DATA_BACKUP/34_2026_04_23_17_28_33.sql.gz" | $MYSQL_CMD "$DB_ELEVATOR"
|
zcat "$DATA_BACKUP/34_2026_04_23_17_28_33.sql.gz" | sed '/GTID_PURGED/d' | $MYSQL_CMD "$DB_ELEVATOR"
|
||||||
log_ok " $DB_ELEVATOR partition 34 restored"
|
log_ok " $DB_ELEVATOR partition 34 restored"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user