We've been trying to create an automatic database backup with a date attached using Crontab. Using this code (available on the Cron help guide)
0 0 * * 1 mysqldump --defaults-file=$HOME/backups/db/database_name.cnf -u database_name database_name > $HOME/backups/db/database_name-'date +%Y%m%d'.sql 2>> $HOME/backups/db/cron.log
Unfortunately, the output doesnt display the date properly: database_name +%Y%m%d.sql
Does anyone know / see what we're doing wrong here?
Thanks in advance,
asked Sep 17 '12 at 10:06
In your example, you're using single-quote characters around the date command, eg:
What you would be using instead is backticks (grave accents), eg:
Hope that helps!
answered Sep 17 '12 at 10:29