I am trying to run the following in cron to back up a server every morning at 4am:
0 4 * * * dump -0uan -f - / | gzip -2 | ssh -c blowfish user@server dd of=/backups/`hostname`_`date '+%m-%d-%Y_%k%M%S'`.dump.gz
Running the command on it's own from the shell works fine. Usually when this happens the problem is due to paths, so I tried adding full paths in cron:
0 4 * * * /sbin/dump -0uan -f - / | /usr/bin/gzip -2 | /usr/bin/ssh -c blowfish user@server /bin/dd of=/backups/`hostname`_`date '+%m-%d-%Y_%k%M%S'`.dump.gz
and still no luck. I checked the system log and saw this:
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file
The same error occurs with and without paths specified. Should be a pretty simple command. Is cron executing this differently than it is written?
Escape the percent sign, or put that whole line in a script and trigger that instead.