Crontab/backup


#1

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:


#2

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


#3

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:

#!/bin/bash
echo "Here it goes!"
suffix=$(date +%y%m%d)
mysqldump --opt -uUser -pPassword -h mysql.domain.com 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 backup.sh. For testing purposes I run it by typing “bash backup.sh”.

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?

-Matttail


#4

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?


#5

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

0 1 * * */3 bash backup/crontab2.sh

and crontab2.sh with

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