I have this cron:
00 0 * * * root /home/bitnami/backup.sh > /home/bitnami/backup.log
The Backup script contains:
#!/bin/bash
cd /tmp
file=$(date +%Y-%m-%d).sql
mysqldump \
--host localhost \
--port 3306 \
-u user \
--password="123" \
bitnami > ${file}
if [ "${?}" -eq 0 ]; then
gzip ${file}
aws --region us-west-2 s3 cp ${file}.gz s3://backups/fc-wiki/
rm ${file}.gz
else
echo "Error backing up mysql"
exit 255
fi
Which works fine when executing it by hand (sudo .\backup.sh)
When the crontab runs it only logs the following error in backup.log:
Error backing up mysql
Is there a problem how I'm setting up the cron tab with the piping to log perhaps? Even without the piping it doesn't work.