diff --git a/modules/backup/mysql-restore-to-sql.sh b/modules/backup/mysql-restore-to-sql.sh index 1555434..bc67af6 100755 --- a/modules/backup/mysql-restore-to-sql.sh +++ b/modules/backup/mysql-restore-to-sql.sh @@ -1556,6 +1556,46 @@ show_recovery_options() { esac } +# Quick Retry Menu - shown when dump fails to let user pick recovery mode +# Returns 0 if user selects recovery mode, 1 if user wants to exit to menu +show_quick_retry_menu() { + echo "" + echo "════════════════════════════════════════════════════════════════" + echo "Dump failed. Which recovery mode would you like to try?" + echo "════════════════════════════════════════════════════════════════" + echo "" + echo " [1] Recovery mode 1 (ignore corrupt pages)" + echo " [2] Recovery mode 2 (prevent background operations)" + echo " [3] Recovery mode 3 (prevent transaction rollbacks)" + echo " [4] Recovery mode 4 (prevent insert buffer merge)" + echo " [5] Recovery mode 5 (skip redo log)" + echo " [6] Recovery mode 6 (skip page checksums - most aggressive)" + echo " [A] Auto-escalate to next mode" + echo " [0] Return to main menu" + echo "" + echo -n "Select: " + read -r recovery_choice + + case "$recovery_choice" in + 0) + return 1 + ;; + [1-6]) + FORCE_RECOVERY="$recovery_choice" + print_warning "Will retry with recovery mode $FORCE_RECOVERY" + return 0 + ;; + A|a) + print_warning "Will auto-escalate to next recovery mode" + return 0 + ;; + *) + print_error "Invalid selection. Returning to menu." + return 1 + ;; + esac +} + # Check available disk space (CRITICAL SAFETY CHECK #3) check_disk_space() { local target_dir="$1" @@ -2612,17 +2652,27 @@ step5_create_dump() { print_error "Failed to start second MySQL instance" echo "" - # Provide intelligent recovery guidance (pass selected database name) - # show_recovery_options now prompts user and returns: + # Show quick retry menu first - lets user pick recovery mode directly # - 0 = user wants to retry (FORCE_RECOVERY updated by function) # - 1 = user wants to return to menu - if show_recovery_options "$TEMP_DATADIR" "$FORCE_RECOVERY" "$DATABASE_NAME"; then + if show_quick_retry_menu; then # User chose to retry with specific mode - return 2 to signal "retry immediately" # (bypass auto-escalation in menu loop) echo "" return 2 else - # User chose to return to menu - return 1 (failure) + # User wants to return to menu or see full troubleshooting + # Ask if they want to see full recovery options + echo "" + echo -n "Would you like to see full troubleshooting options? (y/n): " + read -r show_full + if [ "$show_full" = "y" ]; then + echo "" + if show_recovery_options "$TEMP_DATADIR" "$FORCE_RECOVERY" "$DATABASE_NAME"; then + echo "" + return 2 + fi + fi echo "" return 1 fi