How to --exclude /usr/ but --include /usr/local/ ?

Larry Alkoff labradley at
Tue Jun 7 18:51:49 GMT 2005

Wayne Davison wrote:
> On Sun, Jun 05, 2005 at 11:28:08PM -0500, Larry Alkoff wrote:
>>In looking at man rsync, it does not appear to both
>>--exclude /usr/ and --include /usr/local/
> Correct, you can't exclude /usr and still get to /usr/local.  What you
> want to do is to include /usr/local/ and exclude /usr/local/* (in that
> order) without specifying a rule for /usr (unless you need to override
> a more general exclude).
>>I start rsync at / and the files I wish to save are in /usr/local
>>plus /home and some other directories.
> I'd suggest putting +/- rules into a file and using --exclude-from.  For
> instance:
> + /home/
> + /usr/
> + /usr/local/
> - /usr/local/*
> + /some/
> + /other/
> + /other/directories/
> - /other/*
> - /*
> ..wayne..
Thank you very much _again_ for very informative reply to my question.

In my case I wanted to start at / and include directories of interest to 
me for backup purposes.  /usr is not needed but /usr/local is.

I solved the problem another way some months ago using a for loop which 
selects the directories I want to save.  All except /usr/local start 
from / so I thought it might be possible to simplify the script.  Guess 
I'll stick with the for loop which works well.


Larry Alkoff N2LA - Austin TX
Using Thunderbird on Slackware Linux

More information about the rsync mailing list