LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-11-2014, 02:11 AM   #1
tux111
Member
 
Registered: Oct 2012
Location: Germany
Distribution: Xubuntu
Posts: 81

Rep: Reputation: Disabled
rsync: exclude / include


Dear all,

Code:
rsync -avR /home/chris/ --delete --exclude="temp/" --exclude=".*" --link-dest=../last /media/alteplatte/backups/cd/$TODAY  >> $LOG 2>&1
I've excluded ".*" files in my rsync backup. Now, I want to include ".thunderbird", but not the other .-folders. How can this be done?

- Chris
 
Old 01-11-2014, 07:11 AM   #2
wildwizard
Member
 
Registered: Apr 2009
Location: Oz
Distribution: slackware64-14.0
Posts: 875

Rep: Reputation: 282Reputation: 282Reputation: 282
I don't use include and exclude but rather filter

--filter='+ .thunderbird/***'
--filter='- .*'

If you include anything that is covered by a blanket exclude you must put the include before the exclude.
If you want everything inside a sub directory you use *** not *

The example given is a simple one as the sub directory is directly off the excluded path, if you wanted instead to include some sub sub directory then you would need to do something like this :-

--filter='+ .thunderbird/'
--filter='+ .thunderbird/sub-directory-here/***'
--filter='- .*'

Just a little gotcha when things get complicated.
 
Old 01-11-2014, 10:14 AM   #3
tux111
Member
 
Registered: Oct 2012
Location: Germany
Distribution: Xubuntu
Posts: 81

Original Poster
Rep: Reputation: Disabled
Thank you very much. This is exactly what I was looking for.
 
Old 01-11-2014, 10:58 AM   #4
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
you can also make an excludes.txt file and populate that.

in my backup script that runs on all of the laptops in the house:

Code:
rsync -aviS --exclude-from=${HOMEDIR}/excludes.txt ${PWD}/ ${RUSER}@${RHOST}:${RDIR}/${dow}/ >> ${log} 2>&1
here is a section of the excludes.txt

Code:
$ cat excludes.txt 
- .cache/
- .config/
- .gconf/
- .local/
- .mozilla/
- .thunderbird/
- NFS/
- *.iso
- .steam/
- public/
- .minecraft/
works great. If you wanted to include something else, then you would just use a + foo and your good.
 
Old 01-12-2014, 01:54 AM   #5
tux111
Member
 
Registered: Oct 2012
Location: Germany
Distribution: Xubuntu
Posts: 81

Original Poster
Rep: Reputation: Disabled
Thank you. I don't have so many subdirectories I want to backup, but exlcudes.txt is a clearly arranged list, I'll use when I add more folders.
 
  


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
rsync Include/exclude based on pattern & file size? Geremia Linux - Software 1 01-20-2012 08:49 PM
include and exclude in rsync xeon123 Linux - Newbie 4 05-26-2011 11:27 PM
Rsync: exclude and include filters? JosephS Linux - Software 1 02-03-2011 10:43 PM
Rsync exclude (or include) issue eyeprotocol Linux - General 1 02-09-2010 11:08 PM
rsync include/exclude problems toaster.waffle Linux - Software 4 11-19-2009 09:57 AM

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

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