exclude a pattern but only in the top level

Paul Slootman paul+rsync at wurtel.net
Wed May 15 03:17:08 MDT 2013


On Wed 15 May 2013, Brian K. White wrote:

> Consider the following directory structure
> 
> /foo/aaa/*/*
> /foo/bbb/*/*
> /foo/ccc/*/*
> 
> I want to sync all of /foo,
> but exclude /foo/aaa

> rsync -avz /foo ${DEST}::root

Firstly, I always recommend that with directory transfers you add a
trailing slash to the source, so your command becomes:

rsync -avz /foo/ ${DEST}::root/foo/

Then a filter would be:

- /aaa/
+ /*

Note the leading slash, as your aaa directory is now in the root of the
source. The second line is not really needed in this scenario IMHO

To be honest I'm wondering about your usage of -f ". filter",
I always do --exclude-from=filter


Paul


More information about the rsync mailing list