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

Wayne Davison wayned at
Tue Jun 7 03:01:06 GMT 2005

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

+ /home/
+ /usr/
+ /usr/local/
- /usr/local/*
+ /some/
+ /other/
+ /other/directories/
- /other/*
- /*


More information about the rsync mailing list