Crontab/backup

Crontab/backup

Posted by: decswxaqz
Posted on: 2005-05-13 11:38:00

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 :PEdited by decswxaqz on 05/13/05 11:40 AM (server time).

Re: Crontab/backup

Posted by: decswxaqz
Posted on: 2005-05-14 07:55:00

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

Re: Crontab/backup

Posted by: ardco
Posted on: 2005-05-14 08:29:00

Was hoping you'd get a good answer, but here's a stab at AN answer. :-)

As mentioned in this post, I'll guess an environment issue. $HOME/backup should work, but not sure about ~/backup. Also, it might not find date since its location, /bin/, might not be in cron's path; you might try /bin/date.

Good luck,

BobS

[Edit: punctuation of it's => its]Edited by ardco on 05/14/05 08:31 AM (server time).

Re: Crontab/backup

Posted by: matttail
Posted on: 2005-05-14 19:44:00

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`"

Re: Crontab/backup

Posted by: decswxaqz
Posted on: 2005-05-15 02:20:00

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?

Re: Crontab/backup

Posted by: ardco
Posted on: 2005-05-15 04:25:00

From man 5 crontab:

In reply to:

Step values can be used in conjunction with ranges. Fol­lowing a range with ``/<number>'' specifies skips of the number's value through the range. For example, 0-23/2 can be used in the hours field to specify command execu­tion every other hour ... Steps are also permitted after an asterisk, so if you want to say "every two hours'', just use "*/2''.


So for every x days, use */x in the day of month field.

BobS

Re: Crontab/backup

Posted by: decswxaqz
Posted on: 2005-05-15 05:24:00

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

Tags: mysqldumpcrontab