Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-01-07 11:21:26

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

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

#2 2007-01-07 11:42:20

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

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

#3 2007-01-07 13:02:06

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

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

#4 2007-01-07 15:37:43

hcgtv
Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Re: Linux, crontab, and automatic mysql backups

Offline

#5 2007-01-07 17:45:36

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

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

#7 2007-01-07 20:35:42

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

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

#8 2007-01-08 08:05:07

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

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

Board footer

Powered by FluxBB