Complex include/excludes with rsync?

Matt McCutchen matt at mattmccutchen.net
Fri Jun 11 21:33:15 MDT 2010


On Thu, 2010-06-10 at 19:16 -0400, Brian Mathis wrote:
> I'm trying to use rsync filters to achieve the following result:
> 
> Include /
> Exclude /home
> Include /home/user1
> 
> I've been doing a lot of experimentation and at this point I'm just
> staring at the man page.  Rsync filters seem to be complicated, and a
> result of that I hope they are also powerful.
> 
> How does one achieve this common pattern with rsync?

This has been asked many times before, for example:

http://lists.samba.org/archive/rsync/2007-June/017805.html
http://lists.samba.org/archive/rsync/2008-February/020073.html
http://lists.samba.org/archive/rsync/2009-August/023758.html

The key is that you don't want to actually exclude /home because that
will prevent rsync from even descending to /home/user1 (search the man
page for "ineffectual").  Instead, exclude all the children of /home
other than /home/user1, for example:

+ /home/user1
- /home/*

Alternatively, there is a trick you can do with multiple source
arguments:

http://lists.samba.org/archive/rsync/2006-February/014761.html

-- 
Matt



More information about the rsync mailing list