DB backup cronjob help


I don’t really know anything about cronjobs. I would like to get a basic idea of the best way to attempt to backup my database every hour before I waste lots of time doing it the wrong way.

What I have in my head at the moment is a cronjob that calls a perl program that calls a php program which would do it (I guess email to an external account).

Please advise - Justin


See the wiki article Automatic backup. There’s even a simple line of code already set up there to have the backup E-mailed out to you.

art.googlies.net - personal website


Thanks for the hint, I can’t get it right though.

Using my ftp I made backups and archive directories.

In the backups directory I put in mysql.sh which is…which I chmod to 755 along with the backup directory

cd /home/username/backups/
mkdir mysql
suffix=$(date +%y%m%d)
mysqldump --opt -uUser -ppass -h mysqlA.domain.com db_nameA > mysql/db_nameA.$suffix.sql
mysqldump --opt -uUser -ppass -h mysqlB.domain.com db_nameB > mysql/db_nameB.$suffix.sql
tar zcf archives/mysql_backup.$suffix.tar.gz mysql/*
mutt you@domain.com -a /home/username/backups/archives/mysql_backup.$suffix.tar -s "MySQL Backup"
rm -r mysql/

Then I created a shell account and setup a cronjob which commands simply


now I’m guessing my cronjob is bad but I was also noticing there is no space between the -u and p and the password, is that right?

Thanks for the help - Justin


the lack of space for the user/pass should be correct. Did you create the cronjob from the command line or through the panel? And if you run the script you’ve created, does it work or produce errors? (to run the script type: “bash ./mysql.sh”)

art.googlies.net - personal website


I fixed the fact that I wasn’t sending the compressed tar.

Its all about the mutt command. Seems like the command they gave it outdated. When running it in SSH it keeps saying at a period to the end of the message. I tried adding it to the command and attaching a file as the body with a period. To no avail