Scheduling backups
One thing that is not included in mysqldump
or mysqlpump
is the scheduling of backups. These tools know how to create a backup but not when to. So, this is something where you must use the scheduling services provided by the platform you're using. This is Cron on Linux and macOS, or Task Scheduler if you are on Windows.
Besides creating backups, you probably want to automate cleaning up the oldest backups.
It might be a good idea to put the actual mysqldump
or mysqlpump
command into a shell script or (on Windows) in a .bat
file. Then, you can check returncode
of the process and send an email and/or monitoring alert if the backup fails. You can also use the same script to copy the backup to the cloud or another server.
A very basic scheduled backup on Linux can be created using /etc/cron.d/mysqldump
with the following contents:
0 4 * * * root /user/bin/mysqldump -A > /data/backups/mysql.sql
This creates a backup every day at 04:00AM of all...