Automatically backup mySQL databases


I am still confused exactly how do I automatically backup my sql databases using a cron job. Could some one give me some pointers please.


Here are the relevant Wiki pages:

The first two pages explain how to dump a database to file as well as how to setup a crontab. So the next step would be to determine what logic is involved and if you will need scripting to get it done. The third page is a practical application that also requires scripting:

That is an example of using a simple bash script to dump a couple of databases and archive them into a file with the date as part of the filename.

Hope that helps!

:cool: -//-


I have read all these articles but they do not give you the commands to enter into the Control Panel to add the cron job. I have entered in:

cd /home/alhqetesh/backups/
mkdir mysql
suffix=$(date +%y%m%d)
mysqldump --opt -uUserName -pPassword -h adl_prod_au > mysql/adl_prod.$suffix.sql
tar -cf archives/mysql_backup.$suffix.tar mysql/*
rm -r mysql/

and obviously replaced the username and password with the correct ones. But this seems to fail. The help talks about saving this file to a *.sh and then running that. If that is the case then what would be the command like to execute the shell script?


As shown on the Automatic Back page - the path to the script file. Don’t forgot to chmod the script file to 755.

:cool: -//-