Creating an automatic backup script for mysql
Ok this is really step by step. There’s nothing complicated
1. Created a backup folder as ROOT
> sudo su enter password > cd / > mkdir backup > cd backup
now create a shell script I use NANO to do this. (don’t forget to change the username and password to match yours)
> nano backup.sh cd /backup mysqldump -u username -ppassword --all-databases>backup`date +%a`.sql
Save the file. backup.sh
Now edit the cron table
> crontab -e 01 02 * * * /backup/backup.sh
This will cause your backup to happen every morning at 2am.
It’s a good idea to test your backup routine sh backup.sh before leaving it to cron to do the work.