Automatic MYSQL backup stopped working for some reason


#1

I had a cron job run every week and it worked fine for a year or so. I noticed recently that it stopped working and I don’t know why. I have looked at the crontab through shell and everything looks fine. I also looked at the .sh file and it looks fine too.

I will post the crontab and .sh file, but will change the words/exact paths for security reasons.

crontab:
MAILTO="myemail@mydomain.com"
0 2 * * 6 /home/hidden/backups/mysql.sh

This should run every Saturday at 2:00 am and backup my single MYSQL database.

Mysql.sh

#!/bin/bash
cd /home/hidden/backups/
mkdir mysql
suffix=$(date +%y%m%d)
mysqldump --opt -uhidden -phidden -h localhost.hidden > mysql/hidden.$suffix.sql
tar -cf archives/mysql_backup.$suffix.tar mysql/*
rm -r mysql/

Note: if I run the ./mysql.sh manually it works fine and make a backup of the database. I also do not receive an email showing any errors.

If anyone can help me out with the problem that would be great.


#2

DreamHost does not allow you to store backups on your web hosting accounts. It’s possible that one of their maintenance scripts has found your backups and is removing them.

Try storing it to the DH backup servers

http://wiki.dreamhost.com/Personal_Backup


#3

Also, we already run nightly MySQL backups, so there’s really very little point in running your own unless you store them somewhere outside our data center.


#4

Use full paths inside your script, for mkdir, mysqldump, tar, and rm
If you don’t know the path, type ‘which tar’ and so on. Cron doesn’t necessarily use the same PATH environment that you use in your shell.