Add multi-panel support + safety enhancements to MySQL restore tool

Changes to modules/backup/mysql-restore-to-sql.sh:

Multi-Control Panel Support:
- Source system-detect.sh to detect control panel
- Use SYS_USER_HOME_BASE for restore directory paths
  - cPanel/InterWorx/Standalone: /home
  - Plesk: /var/www/vhosts
- Fixes issue where InterWorx/Plesk don't have /home directories

SQL Output Location Fix:
- Changed output from current working directory to restore directory
- SQL files now saved to parent of TEMP_DATADIR
  Example: /home/temp/restore20251210/ (not /root/)
- Prevents cluttering control panel system directories
- Added print_info showing exact save location before dump

Safety Enhancements:
- Added check_disk_space() function (validates 2x required space)
- Added warn_force_recovery() function (levels 5-6 require risk acknowledgment)
- Integrated disk space check before dump creation
- Integrated force recovery warnings in step4_configure_options()
- Added cleanup trap handler for Ctrl+C/interruption
- Critical safety check prevents using /var/lib/mysql as restore dir

Changes to REFDB_FORMAT.txt:
- Documented multi-control panel support
- Added control_panel_paths section with all 4 panel paths
- Updated output location documentation
- Added safety features documentation
- Updated features list

QA Status:  PASSED
- 0 CRITICAL issues
- 0 HIGH issues
- Syntax validated
- All safety checks functional
This commit is contained in:
cschantz
2025-12-10 21:04:54 -05:00
parent 24becbd06b
commit 92bbf385e3
2 changed files with 48 additions and 13 deletions
+23 -2
View File
@@ -1827,9 +1827,12 @@ use_case:
solution: "Start second MySQL instance with restored files, dump to SQL, import to live"
features:
- "Multi-control panel support (cPanel, Plesk, InterWorx, standalone)"
- "Detects control panel and uses appropriate home directory"
- "Detects MySQL version (MySQL 5.7, MySQL 8.0+, MariaDB)"
- "Version-specific validation (ib_logfile0/1 vs #innodb_redo)"
- "Auto-creates timestamped restore directory (/home/temp/restoreYYYYMMDD/mysql)"
- "Auto-creates timestamped restore directory ($SYS_USER_HOME_BASE/temp/restoreYYYYMMDD/mysql)"
- "SQL dumps saved to restore directory (not current working directory)"
- "Lists exact files needed from backup (with emoji visual markers)"
- "Validates data structure before proceeding"
- "Checks and fixes file ownership (mysql:mysql)"
@@ -1953,7 +1956,25 @@ output:
format: "<database_name>_restored_<timestamp>.sql"
example: "myuser_wordpress_restored_20251210_143022.sql"
with_ticket: "myuser_wordpress_ticket01234567_20251210_143022.sql"
location: "Current working directory"
location: "Parent directory of restore location (e.g., /home/temp/restore20251210/)"
control_panel_paths:
cpanel:
home_base: "/home"
suggested_restore: "/home/temp/restore20251210/mysql"
sql_output: "/home/temp/restore20251210/"
plesk:
home_base: "/var/www/vhosts"
suggested_restore: "/var/www/vhosts/temp/restore20251210/mysql"
sql_output: "/var/www/vhosts/temp/restore20251210/"
interworx:
home_base: "/home"
suggested_restore: "/home/temp/restore20251210/mysql"
sql_output: "/home/temp/restore20251210/"
standalone:
home_base: "/home"
suggested_restore: "/home/temp/restore20251210/mysql"
sql_output: "/home/temp/restore20251210/"
next_steps_provided:
1: "Verify dump: grep 'Dump completed on' output.sql"