diff --git a/modules/backup/mysql-restore-to-sql.sh b/modules/backup/mysql-restore-to-sql.sh index 76830a5..ebdd69a 100755 --- a/modules/backup/mysql-restore-to-sql.sh +++ b/modules/backup/mysql-restore-to-sql.sh @@ -275,7 +275,7 @@ show_recovery_options() { local memory_issue="" if [ -f "$error_log" ]; then - if grep -qE "Cannot open tablespace|Tablespace.*missing|Unable to open" "$error_log"; then + if grep -qE "Cannot open tablespace|Tablespace.*missing|Tablespace.*was not found|Unable to open" "$error_log"; then missing_files="yes" fi if grep -qE "Corrupted|Database page corruption" "$error_log"; then @@ -303,9 +303,16 @@ show_recovery_options() { # Extract tablespace names from various error patterns while IFS= read -r error_line; do - # Pattern 1: "Cannot open tablespace 'db/table'" - if echo "$error_line" | grep -qE "Cannot open|Unable to open|Tablespace.*missing"; then - local tablespace=$(echo "$error_line" | grep -oE "'[^']+'" | tr -d "'" | head -1) + # Pattern 1: "Cannot open tablespace 'db/table'" or "Tablespace N was not found at ./db/table.ibd" + if echo "$error_line" | grep -qE "Cannot open|Unable to open|Tablespace.*missing|was not found at"; then + # Try to extract path from "was not found at ./path/table.ibd" + local tablespace=$(echo "$error_line" | grep -oE '\./[^/]+/[^.]+\.ibd' | sed 's|\./||;s|\.ibd||' | head -1) + + # Fallback: try to extract from quoted tablespace name + if [ -z "$tablespace" ]; then + tablespace=$(echo "$error_line" | grep -oE "'[^']+'" | tr -d "'" | head -1) + fi + if [ -n "$tablespace" ]; then missing_list+=("$tablespace") missing_count=$((missing_count + 1)) @@ -320,7 +327,7 @@ show_recovery_options() { missing_count=$((missing_count + 1)) fi fi - done < <(grep -iE "Cannot open|Unable to open|Tablespace.*missing|Cannot find space id" "$error_log" 2>/dev/null) + done < <(grep -iE "Cannot open|Unable to open|Tablespace.*missing|was not found at|Cannot find space id" "$error_log" 2>/dev/null) if [ "$missing_count" -gt 0 ]; then print_warning "MISSING FILES DETECTED ($missing_count found):" @@ -351,7 +358,7 @@ show_recovery_options() { print_warning "Could not parse specific missing files from error log" echo "Showing raw error lines:" echo "" - grep -iE "Cannot open|Unable to open|Tablespace.*missing" "$error_log" 2>/dev/null | head -10 + grep -iE "Cannot open|Unable to open|Tablespace.*missing|was not found at" "$error_log" 2>/dev/null | head -10 echo "" fi