This script performs a backup of a MySQL database with the following features:
-
Configuration:
- Reads configuration from a specified file.
- Supports different roles (master/slave) for database configuration.
- Configurable backup directory, number of threads, and other settings.
-
Password Generation:
- Generates a random password for the zip file containing the backup.
-
MySQL Command Check:
- Verifies the availability of MySQL client tools (
mysql
andmysqldump
).
- Verifies the availability of MySQL client tools (
-
Backup Directory Management:
- Creates a target directory for the backup.
- Removes old backup directories if they exist.
-
Table Dumping:
- Dumps each table from the database into a SQL file.
- Compresses each SQL file into a password-protected zip file.
- Tracks dumped tables to support resuming interrupted backups.
-
Log Table Filtering:
- Optionally skips tables that are identified as log tables.
-
Parallel Execution:
- Uses a thread pool to dump tables in parallel for faster execution.
-
Error Handling:
- Logs errors and failed tables.
- Sends error notifications via Telegram.
-
Backup Completion:
- Creates a final zip file containing all table dumps.
- Writes the path of the zip file to a tracking file.
- Sends a completion message via Telegram with backup details.
-
Telegram Notifications:
- Sends messages to a specified Telegram chat for important events and errors.