Add comprehensive documentation for all 20 functions
Documentation Coverage: - Total functions: 20 - Previously documented: 13 - Now documented: 20 (100% coverage) Added Function Descriptions: - show_intro: Script overview banner - step1_detect_datadir: Auto-detect/prompt for MySQL directory - step2_set_restore_location: Configure temporary restore directory - step3_select_database: Database selection from restored data - step4_configure_options: InnoDB recovery and ticket options - step5_create_dump: SQL dump creation and validation - main: Orchestrate the 5-step workflow Each function now includes: - Clear one-line purpose statement - Parameter descriptions where applicable - Key variables set or used - Main workflow steps Impact: Significantly improves code maintainability and makes it easier for new developers to understand the script structure and workflow. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1233,6 +1233,8 @@ dump_database() {
|
||||
# INTERACTIVE WORKFLOW
|
||||
################################################################################
|
||||
|
||||
# Display the welcome banner and script overview to the user
|
||||
# Explains what the script does and shows required steps
|
||||
show_intro() {
|
||||
clear
|
||||
print_banner "MySQL/MariaDB File-Based Restore"
|
||||
@@ -1290,6 +1292,9 @@ show_intro() {
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Step 1: Auto-detect or prompt for live MySQL data directory
|
||||
# Looks for running MySQL instance or attempts to find config file
|
||||
# Sets LIVE_DATADIR variable for use in later steps
|
||||
step1_detect_datadir() {
|
||||
print_banner "Step 1: Detect Live MySQL Data Directory"
|
||||
|
||||
@@ -1341,6 +1346,10 @@ step1_detect_datadir() {
|
||||
press_enter
|
||||
}
|
||||
|
||||
# Step 2: Configure temporary location for restored MySQL data
|
||||
# Allows user to choose suggested directory or provide custom path
|
||||
# Validates path for safety (no traversal, not live MySQL dir)
|
||||
# Sets TEMP_DATADIR variable for second MySQL instance
|
||||
step2_set_restore_location() {
|
||||
print_banner "Step 2: Set Restored Data Location"
|
||||
|
||||
@@ -1575,6 +1584,10 @@ step2_set_restore_location() {
|
||||
press_enter
|
||||
}
|
||||
|
||||
# Step 3: Allow user to select which database to extract from the restored data
|
||||
# Lists available databases from TEMP_DATADIR and prompts for selection
|
||||
# Validates database directory exists before proceeding
|
||||
# Sets DATABASE_NAME variable for dump operation
|
||||
step3_select_database() {
|
||||
print_banner "Step 3: Select Database to Restore"
|
||||
|
||||
@@ -1641,6 +1654,10 @@ step3_select_database() {
|
||||
press_enter
|
||||
}
|
||||
|
||||
# Step 4: Configure InnoDB recovery options and ticket information
|
||||
# Allows user to set InnoDB force recovery level if needed (0-6)
|
||||
# Prompts for optional ticket number for tracking purposes
|
||||
# Shows analysis-based recovery recommendations from error logs
|
||||
step4_configure_options() {
|
||||
print_banner "Step 4: Configure Restore Options"
|
||||
|
||||
@@ -1700,6 +1717,10 @@ step4_configure_options() {
|
||||
press_enter
|
||||
}
|
||||
|
||||
# Step 5: Create SQL dump from the restored database using second MySQL instance
|
||||
# Starts isolated MySQL instance, dumps selected database, validates integrity
|
||||
# Generates .sql file with optional ticket number in filename
|
||||
# Cleans up second instance and provides import instructions
|
||||
step5_create_dump() {
|
||||
print_banner "Step 5: Create SQL Dump"
|
||||
|
||||
@@ -1813,6 +1834,10 @@ step5_create_dump() {
|
||||
# MAIN EXECUTION
|
||||
################################################################################
|
||||
|
||||
# Main entry point: orchestrates the 5-step workflow to extract SQL from restored backup
|
||||
# Detects MySQL location, validates restore files, starts second instance,
|
||||
# creates SQL dump, and provides usage instructions
|
||||
# Handles errors and signal interrupts with proper cleanup
|
||||
main() {
|
||||
show_intro
|
||||
echo -n "Continue? (y/n, or 0 to cancel): "
|
||||
|
||||
Reference in New Issue
Block a user