This is a Perl job.
I just need a Perl script that backs up MySQL databases using mysqldump. I will run it from CRON.
It needs these editable settings (variables within the script):
- MySQL host.
- MySQL user name.
- MySQL user password.
- Databases to exclude.
- Backup location (a directory on the system).
- Compression (Y/N).
It needs to do this:
- Back up all tables of all databases except those databases that are excluded.
- Create a master backup directory named using the current date/time in this format: YYYY_MM_DD_HH_MM.
- Create a backup directory for each database. Name it the same as the database. Put it into the master directory.
- Create a dump file for each table. Text file should contain structure and data. Name each dump file the same as the name of the table. Put all dump files for each database into the backup directory created for that database.
- Create a gzip archive of the master directory if compression = Y.
- Move the master directory or archive to the backup location.
- Clean up temp files. The only think left should be the file/directory placed into the backup directory.
The server is LAMP.