mysqldump and cron advice needed

Subscribe to mysqldump and cron advice needed 2 post(s), 1 voice(s)

 
Avatar michael 4 post(s)

Hi all

Hoping someone can offer some advice … once a week, I take a mysqldump backup of my database. I always run this command from a terminal screen:

mysqldump -h sqlreadwrite.brightbox.net -p"PASSWORD" -u"USERNAME" USERNAME_APPNAME_production | gzip > /home/rails/backup_$(date +%Y%m%d).sql.gz

It works perfectly. To save me logging in once a week, I want to set it up as a cron job which runs every Sunday and on the 1st of each month. I’ve used crontab -e to add the following line to my crontab file:

0 7 1 * 0 mysqldump -h sqlreadwrite.brightbox.net -p"PASSWORD" -u"USERNAME" USERNAME_APPNAME_production | gzip > /home/rails/backup_$(date +%Y%m%d).sql.gz

Nothing seems to happen (there’s no backup file created). I first thought I’d scheduled it to only run on Sunday’s that are the first of the month but I’ve also tried 0 7 * * * to no avail. I have a suspicion it might be something to do with the pipe but any advice would be greatly appreciated.

Thanks

Mike

 
Avatar michael 4 post(s)

Hi again

Just to say that I think this was to do with the pipe. I moved the command into an external .sh file then called that file from cron and it worked perfectly.

Extra note: I store the .sh file in a subversion repository. I needed the following command to mark it as executable:

svn propset svn:executable '' file.sh

Cheers!

Mike

Signup or login to contribute