LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-02-2014, 09:59 PM   #1
Garrett85
Member
 
Registered: Jan 2011
Posts: 332

Rep: Reputation: 6
getting rsync to ignore


I am currently using rsync to sync my music library to my SD care. I'm using the command 'rsync -a --delete SRC DEST' The problem is I'd also like to sync my audio books directory which is not a sub directory of my music folder. Using my current command rsync will delete my audio books folder every time I run the command. Anyone know how I can change my command so that rsync will ignore the audio books folder? Thanks.
 
Old 11-03-2014, 12: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
See "--exclude". Always test with "--dry-run" or "-n".
 
Old 11-05-2014, 12:38 AM   #3
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
Originally Posted by Garrett85 View Post
... I'm using the command 'rsync -a --delete SRC DEST' ...
Could you tell us the exact commands that you used?

I am guessing you used commands of this form:
Code:
rsync -a --delete ~/music/ /media/sdcard
rsync -a --delete ~/audiobooks/ /media/sdcard
Note the trailing slash (the slash character at the end of the source directory). This is a problem. It tells rsync to transfer the files in ~/music or ~/audiobooks, and not the directories themselves, to /media/sdcard, and delete anything else in /media/sdcard.

One solution is to omit the trailing slash:
Code:
rsync -a --delete ~/music /media/sdcard
rsync -a --delete ~/audiobooks /media/sdcard
This tells rsync to transfer the directories ~/music and ~/audiobooks complete with their contents. It will create destination directories /media/sdcard/music and /media/sdcard/audiobooks, and the scope of the --delete option will be limited to the respective destination directory. I think that will keep all the files you intended to keep.

For the sake of completeness, I point out that the above transfer can also be accomplished with the trailing slash on the source (meaning "files in" that directory) and specifying the full destination directory, for example:
Code:
rsync -a --delete ~/music/ /media/sdcard/music
rsync -a --delete ~/audiobooks/ /media/sdcard/audiobooks
This would create directories /media/sdcard/music and /media/sdcard/audiobooks and put the corresponding files in them.

Edit: In rsync, a trailing slash on the destination doesn't do anything. It doesn't make a bit of difference. Therefore, if you are not sure (don't remember) which one the trailing slash is supposed to go on, and you don't want to read the manual, go ahead and put it on both:
Code:
rsync -a --delete ~/music/ /media/sdcard/music/
rsync -a --delete ~/audiobooks/ /media/sdcard/audiobooks/

Last edited by Beryllos; 11-05-2014 at 01:06 AM. Reason: I added the last paragraph and code block
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] what is the rsync flag to ignore permissions replica88 Linux - Newbie 4 05-01-2019 02:49 PM
How to get rsync to ignore Directories but include files. Shemlik Linux - Newbie 1 09-02-2014 06:12 AM
make rsync ignore directory structure? illumilore Linux - General 1 04-20-2011 12:46 AM
[SOLVED] rsync still copies with ignore existing option digity Linux - Newbie 2 07-14-2010 01:12 PM
rsync ignore files Eazy-Snatch Linux - Networking 3 09-18-2006 06:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:58 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