Backup all MySQL databases into seperate files with crontab
It's highly recommended to keep a backup of all your data and with the following script you can setup an automated task to create a weekly backup of your data without having to manually run it; with linux!
The Shell Script "db-backup.sh"
Next Step Add to Crontab
In order for the script that we have created to be executed automatically we need to add this to the crontab task scheduler.
View existing crontab scheduled tasks
Edit the crontabs
Normally you specify the exact minute, hour, day, week, month with the either with an asteric character * (which means every) or a numeric character (which represents moments in time
The crontab also has special keywords which are predfined values
string meaning ------ ------- @reboot Run once, at startup. @yearly Run once a year, "0 0 1 1 *". @annually (same as @yearly) @monthly Run once a month, "0 0 1 * *". @weekly Run once a week, "0 0 * * 0". @daily Run once a day, "0 0 * * *". @midnight (same as @daily) @hourly Run once an hour, "0 * * * *". @daily
Add the backup script to the crontab
@weekly /path/to/backup-script.shcomments powered by Disqus