Help with a mysql data dump command

Hello all,

I’m trying to modify my mysql data dump command to include the date in the backup, but it keeps throwing errors. I’m hoping someone who is more skilled with mysql/cpanel could lend a hand.

here’s the two variations of the command I tried with both of them throwing the same error when the cron job runs:

mysqldump -u*removed* -p*removed* *dbname* | gzip > /directory/for/the/backup/tsn_gzip_.`date +%m%d%y`.sql.gz
mysqldump -u*removed* -p*removed* *dbname* | gzip > /directory/for/the/backup/tsn_gzip_`date +%m%d%y`.sql.gz

here’s the error:
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``’
/bin/sh: -c: line 1: syntax error: unexpected end of file

any help would be greatly appreciated.


I figured it out. to get it to work, I had to add a few \ between the dates, like so:

mysqldump -u*removed* -p*removed* *dbname* | gzip > /directory/for/the/backup/tsn_gzip_.`date +\\%m\\%d\\%y`.sql.gz