LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 04-03-2012, 02:08 PM   #1
secretlydead
Member
 
Registered: Sep 2003
Location: Qingdao, China
Distribution: mandriva, slack, red flag
Posts: 248

Rep: Reputation: 31
crontab rsync backup across servers


Hi,

I'm trying to backup my server everyday. The first of these commands is not running in cron:

0 2 * * * /usr/bin/rsync -ab --backup-dir=/home/back/backup/site/old_`date +%F` --exclude=/admin/ppc/sos/reports/ --exclude=/admin/templates_c/ user@host:/home/user/public_html/ /home/back/backup/site/

10 2 * * * /usr/bin/rsync -ab user@host:/home/user/backup/ /home/back/backup/db


but BOTH of these commands work from the command line.
 
Old 04-03-2012, 02:20 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, Ubuntu, SLES, CentOS
Posts: 1,768

Rep: Reputation: 322Reputation: 322Reputation: 322Reputation: 322
@ Reply

Hi secretlydead,

Instead of mentioning the command you can create a small script for these commands. As you said that first one doesn't work but second one does so it appears that the command is getting truncated when cron tries to execute.

Better is to create a file say backup.sh and put the first command in there and then put an entry for that script in cron and it should work.
 
Old 04-03-2012, 02:35 PM   #3
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
As T3RM1NVT0R suggested, better to create a script and run it from crontab. Anyway, the problem is the % sign in the date format, that has a special meaning in crontab. From man 5 crontab:
Quote:
Percent-signs (%) in the command, unless escaped with backslash (\), will
be changed into newline characters, and all data after the first % will
be sent to the command as standard input.
Escaping it should do the trick.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Rsync Backup for Windows, Linux Knoppix, and Other Smart Technologies in Handy Backup by Novos LXer Syndicated Linux News 0 12-24-2011 11:43 AM
[SOLVED] rsync execution issue with crontab - Have given full path to rsync too!! Prabagaran Linux - Server 6 04-15-2011 01:39 AM
LXer: Backup with rsync and rsync.net LXer Syndicated Linux News 0 09-14-2010 04:20 PM
Crontab rsync does not backup to NAS device Astol Linux - Software 1 09-24-2008 12:04 AM
Backup with rsync and crontab gjblackford Linux - General 4 01-04-2007 08:53 AM


All times are GMT -5. The time now is 02:18 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration