I have a shell script that backups a database, 7zips it, and uploads to my Amazon s3 account. It works if I run the shell script, but as a cronjob it stops after it dumps the database (doesn't continue on to 7zip). Can anybody see what I am doing wrong here?
Here is the line in my crontab:
59 2 * * 0 cd / && ./mysqlbackup.sh >/dev/null 2>&1
Here is mysqlbackup.sh :
!/bin/sh
DMPFILE=fc$(date +"%Y%m%d").dmp BACKUPFILE=fc$(date +"%Y%m%d").7z
# Dump Database mysqldump --quick --add-drop-table --add-locks --extended-insert --lock-tables --opt -u **** -p**** database_name > $DMPFILE
# Zip Dump
7za a $BACKUPFILE $DMPFILE
# Upload Zip
MONTH=$(date +"%Y%m")
sudo s3cmd put $BACKUPFILE s3://fcmysqlbackup/$MONTH/$DMPFILE
# Delete Local Dump and Zip
sudo rm $DMPFILE $BACKUPFILE
[link][22 comments]