LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-25-2015, 01:28 AM   #1
hexxxx
LQ Newbie
 
Registered: Jul 2015
Posts: 2

Rep: Reputation: Disabled
Rsync and cron are driving me crazy! Duplicate backups, parameters ignored.


I'm trying to set a nightly backup using cron. When I run the command via terminal I get no issues, but with cron the code runs disregarding the parameters (e.g. the excluded directories). This gives me tiers of duplicates until the external drive is full. What is wrong with my code? Why is it running normally via terminal? I've been struggling over this for hours. I'm on Linux Mint 17.1.

Code:
sudo crontab -e

00 00 * * * sudo mount /dev/sdb1 /media/x/; sudo rsync -aAXv --delete --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/home/x/Downloads/*","/home/x/Music/*"} /* /media/x/backup > $HOME/`date +\%Y\%m\%d\%H\%M\%S`-cron.log 2>&1
Thank you!
 
Old 07-25-2015, 02:44 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
BASH brace expansion vs whatever shell cron uses?
As in just write those --exclude= items out instead?
 
Old 07-25-2015, 03:27 AM   #3
hexxxx
LQ Newbie
 
Registered: Jul 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for your help. Still not having any luck. I was a bit confused by your response so I went searching around StackExchange and found some advice to switch the crontab shell using:

Code:
SHELL=/bin/bash
I didn't have any luck with that, and wasn't able to get my cron file to run at all. Would you mine posting an example of what you meant? I think cron runs with shell rather than bash.
 
Old 07-25-2015, 03:40 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by hexxxx View Post
Would you mine posting an example of what you meant?
I only meant you should write them excludes out one by one like "--exclude=/dev/ --exclude=/sys/" and so forth.
- cron will mail errors to the owner of that crontab so do check that mail box. (Obviously that won't work if the problem resides elsewhere.)
- sudo might not work (requires terminal access for pass phrase) unless you have explicit NOPASSWD entries for this user and those commands.
- When stuff doesn't work rsync-wise do note you can (should?) make the process more verbose. So until stuff gets fixed you could add "-n -v --logfile=/tmp/somefile --itemize-changes --stats".
 
  


Reply



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
RSync error syncing over ssh driving me crazy hazey11 Linux - Server 4 02-26-2012 02:17 PM
Driving me crazy!!! fusion1275 Programming 3 10-15-2008 05:19 PM
XMMS ,driving me crazy !!!! waelaltaqi Linux - Software 3 12-11-2005 03:26 AM
[ ] @ are driving me crazy FireInTheDark Linux - Software 1 11-28-2004 09:42 AM
Help this is driving me crazy!!!!!! Wolfy Linux - Hardware 1 07-07-2004 01:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:30 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration