Automatically backup mySQL databases


#1

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.


#2

Here are the relevant Wiki pages:

http://wiki.dreamhost.com/Crontab
http://wiki.dreamhost.com/Backup_MySQL
http://wiki.dreamhost.com/Automatic_Backup

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:

http://wiki.dreamhost.com/Automatic_Backup#Mysql_Database_Backup

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: openvein.org -//-


#3

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:

#!/bin/bash
cd /home/alhqetesh/backups/
mkdir mysql
suffix=$(date +%y%m%d)
mysqldump --opt -uUserName -pPassword -h msql.adultlovehub.com 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?


#4

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

:cool: openvein.org -//-