cron job not working - what am i doing wrong?

Joined
12 Feb 2006
Posts
17,380
Location
Surrey
i've never used cron before so unsure what i'm doing wrong, but unfortunately the script i've got from online doesn't work.

below is the script i have which is save as 'mysql_autobackup.sh'

Code:
#!/bin/sh
#change directory to your backup directory
cd /home/websiteNameFolder/db_backup/;
#get backup of database of applications
mysqldump --user='[removed username]' --password='[removed password]' mydb >databaseName.sql;
#compress it in zip file
zip app_database-$(date +%Y-%m-%d-%H:%M).sql.zip tmp_db.sql;
#remove  sql file
rm -rf tmp_db.sql;
#delete backups older than 20 days
find /home/websiteNameFolder/db_backup/app* -mtime +30 -type f -delete;


i've edited out some bits.

then on cronjobs i have the following to run sunday at 4am using the following.

Code:
0    4    *    *    0

Code:
/home/websiteNameFolder/db_backup/mysql_autobackup.sh

but nothing happens. i checked the folder and no backup there. is there a way to see why it failed?

one thing i'm not sure on if where it says "mydb >" i assumed this was my database name so put that there, but then it has the .sql so wasn't convinced i was correct.

thanks
 
Back
Top Bottom