How to exclude directories from source with --relative

Stuart Anderson anderson at
Thu May 29 22:40:08 GMT 2008

On Tue, May 27, 2008 at 03:18:03PM -0400, Matt McCutchen wrote:
> On Mon, 2008-05-26 at 23:40 -0700, Wayne Davison wrote:
> > On Mon, May 26, 2008 at 09:46:04PM -0700, Stuart Anderson wrote:
> > > 3) Try excluding a/, this does not work:
> > > 
> > > # rsync -avn --relative --exclude a/ /tmp/source/./a/? /tmp/destination
> > 
> > That's because 'a' is an implied directory in the longer path that you
> > told rsync to transfer.  Implied directories can't be excluded, but
> > their attributes can be omitted via --no-implied-dirs.  If you don't
> > want it in the transfer, don't specify it (and if you're using wild-
> > cards, specify them in such as way as to avoid matching the dir you
> > don't want).
> I can understand not being able to exclude a/ from the file list while
> still transferring stuff under it.  Still, I should be able to exclude
> a/ and everything under it by passing --exclude='/a/***' .  But this
> doesn't work in rsync 3.0.2: rsync excludes a/b but adds the implied dir
> a/ to the file list anyway.  (Obviously, it worked in rsync 2.6.9, which
> allowed the user to exclude implied dirs.)  I think rsync should check
> whether a source argument is excluded before adding any dirs it implies.

This would be sufficient for my needs, and I didn't realize it is a
change in behavior from 2.6.9 to 3.0.2.


Stuart Anderson  anderson at

More information about the rsync mailing list