I am trying to create a cron job to back up a database.
This is what I still have:
mysqldump.sh
mysqldump -u root -ptest --all-databases | gzip > "/db-backup/backup/backup-$(date)" 2> dump.log
echo "Finished mysqldump $(date)" >> dump.log
Cron task:
32 18 * * * /db-backup/mysqldump.sh
The problem that I encountered is that the task is not executed via cron or when I am not in the directory.
Can someone consult. Are my ways wrong?
In addition, the following line, which I'm not sure, will throw errors in dump.log:
mysqldump -u root -ptest --all-databases | gzip > "/db-backup/backup/backup-$(date)" 2> dump.log
What worked:
mysqldump -u root -ptest --all-databases | gzip > "../db-backup/backup/backup-$(date).sql.gz" 2> ../db-backup/dump.log
echo "Finished mysqldump $(date)" >> ../db-backup/dump.log
source
share