How to exclude directories from source with --relative

Stuart Anderson anderson at
Tue May 27 17:43:00 GMT 2008

On Mon, May 26, 2008 at 11:40:31PM -0700, Wayne Davison wrote:
> On Mon, May 26, 2008 at 09:46:04PM -0700, Stuart Anderson wrote:
> > # rsync -avn --relative --exclude b/ /tmp/source/./a/? /tmp/destination
> That excludes all "b" dirs.  It's safer to exclude "/a/b/" (anchored and
> fully specified).  The simple rule is to exclude the names that rsync
> outputs via -v.
> > 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).

Nuts. I was afraid that was going to be the answer. Unfortunately,
it violates the very helpful advise given above, i.e., run with "-v"
and add exclude rules for files you don't want to transfer based
on the output seen.

Is this an enhancement request you are willing to consider, i.e.,
allow filtering of implied directories?

The real problem I want to solve has a pattern matching requirement
that is too complicated for a glob that specifies the implied
directories, and while the explicit list can be generated outside
of rsync it would be much more convenient to use rsync's --exclude


Stuart Anderson  anderson at

More information about the rsync mailing list