Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Linux, crontab, and automatic mysql backups
I admit: I have no clue of Linux. And I could use some advice on this:
I followed this FAQ entry in order to have an automated backup for my database. Entering said command on the shell prompt worked as expected,so I tried to add an entry into the crontab using crontab -e
:
0 0 * * 0 mysqldump -Qc -u xxxxxxx -h mysql.domain.tld --password=passwd database_name | gzip > $HOME/dbbackup/xxxxxxxx_txpprod_backup-`date '+%Y%m%d'`.sql.gz
The crontab entry was accepted properly, so the job scheduling shouldn’t impose any problem. Sadly, the job itself won’t run but throws this error message at me:
/bin/sh: -c: line 1: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 2: syntax error: unexpected end of file
How could I proceed?
Offline
Re: Linux, crontab, and automatic mysql backups
Backticks are an old, outdated and no longer recommended way to invoke subshells. Try using $() instead. So the relevant part of the line would look like:
ckup-$(date '+%Y%m%d').sq
Offline
Re: Linux, crontab, and automatic mysql backups
Done that, results in the exactly same error message. I suspect, I’ll have to get a grip on unix shells… These phpMyAdmin based manual backups are just annoying.
Offline
Re: Linux, crontab, and automatic mysql backups
We Love TXP . TXP Themes . TXP Tags . TXP Planet . TXP Make
Offline
Re: Linux, crontab, and automatic mysql backups
It can’t (well, shouldn’t) be exactl the same message, for the simple reason that you should not have any backticks left in the line – therefore it shouldn’t try to match any backticks. It sounds like you might have a runaway backtick somewhere in the line, or maybe a missing (or one too many) line-break(s). Either that, or you have problems with escaping or other special characters. Though I can’t see any of that in the snippet you posted, it seem to be the explanation that makes most sense.
Offline
#6 2007-01-07 19:54:57
- marios
- Archived Plugin Author
- Registered: 2005-03-12
- Posts: 1,253
Re: Linux, crontab, and automatic mysql backups
I don’t know, if this is of any help. but this is how it works on tXD.
mysqldump -Qc -u xxxxxxx -h mysql.domain.tld --user=uname --password=passwd database_name | gzip > $HOME/dbbackup/xxxxxxxx_txpprod_backup_`date "+%Y-%m-%d"`.gz
( Adapted to yours, except there are a couple of additional parameters. Everithing is on one line without lin-breaks, but yours was as well.)
regards, marios
(The strike-through is due to forum-textile and the smart-quotes need to be done back to normal quotes of course)
Edit: all you needed was another line break marios ;) -Els
Last edited by els (2007-01-07 22:55:49)
⌃ ⇧ < ⎋ ⌃ ⇧ >
Offline
Re: Linux, crontab, and automatic mysql backups
Thanks to all of you, unfortunately I haven’t had any luck with the crontab entries so far.
The error message stays the same despite a lack of back ticks as far as I can see. Looks like I’ll have to dive into *nix shells sooner than I’d expected.
Meanwhile, I followed Bert’s recommendation which works. Rotating backups – Nice.
Offline
Re: Linux, crontab, and automatic mysql backups
hi wet… There is this method in textdrive… Hope it may work for you
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline