35 * * * * mysqldump -u user -ppassword -h host dbbackup > ~/backup/date %Y_%m_%d_%M_site_backup.sql

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

I’m using the top line and getting those errors… does anyone know what’s wrong? If I just copy/paste the mysqldump line it works fine.
I’ve got that stored in a file called crontab.txt and using “crontab crontab.txt” to use crontab.

EDIT: Yes I have looked at the KB and wiki, searched the forums and googled it :stuck_out_tongue:

Sorry for the bump, but anyone know?
I’d just rather not waste DH’s time with this as it seems so trivial…

if copy and past is working for you, I suspect that the problem lies in your typing. I was hainving a bit of a problem with this when I set up something similiar. As that code looks familiar, I’m also gonna guess you took it from the thread that where I posted that stuff. Anyways…

when you thpe the ` thingy, are you using the key that’s just to the left of 1? it’s not a single quote, but this sideways quote thing. That can make a big difference. The other thing to keep in mind is that every thing is CaseSenSitive, so make sure there’s no capitlas in your line that shouldn’t be there.

Here’s the code I’m using, you can compare if you want:

echo "Here it goes!"
suffix=$(date +%y%m%d)
mysqldump --opt -uUser -pPassword -h database_name > backups/mysql/database_name.$suffix.sql
echo "I dumped exlibrisbitsy_mt3 succesfully at date +%r"

That’s stored in a basic text file name For testing purposes I run it by typing “bash”.

You’ll also want to make sure that the entire mysqldump command is on one line. If it wraps onto a seconed line it won’t work. Search the forum for the parameter to pass to your text editor to turn off text wrapping (but I think it pico -w or whatever text editor you’re using.)

Does this help?


Yes I was using the ` and not '.
Mysqldump is all on one line. I’m making it in Windows and uploading to my site, so maybe it’s Windows crlf type problem (uploading in ascii).
Tried your script but how do I tell it to do it every xx days?

Got it working now. Using two files.
crontab.txt to set up the time and dates with

0 1 * * */3 bash backup/

and with

suffix=$(date +%y_%m_%d)
mysqldump --opt -uuser -ppassword -h host db > backup/$suffix-site_backup.sql