I would like to backup my MySQL database with a cron job, but I cannot make it work.
This is the code that I am using:
0 2 * * * mysqldump -u root toko_db | gzip > /var/backup/toko_db_`date '+%Y-%m-%d'`.sql.gz
I would like to backup my MySQL database with a cron job, but I cannot make it work.
This is the code that I am using:
0 2 * * * mysqldump -u root toko_db | gzip > /var/backup/toko_db_`date '+%Y-%m-%d'`.sql.gz
The date section for the file name seems malformed. Perhaps you could try this:
0 2 * * * mysqldump -u root toko_db | gzip > /var/backup/toko_db_$(date +\%Y-\%m-\%d).sql.gz
Remember to send that file to another location so that you have a recent backup in the event the entire server disappears.