--exclude patterns

Wayne Davison wayned at samba.org
Sat Jan 26 18:27:03 GMT 2008

On Fri, Jan 25, 2008 at 06:02:07PM -0800, Randy Dunlap wrote:
> rsync --include='/test/runs/***' \
> --exclude='--exclude=/test/runs/? --exclude=/test/runs/?? --exclude=/test/runs/??? --exclude=/test/runs/1???' \
> -avz -e ssh --progress --delete $srcdir $dest:$destdir/

Firstly, the weird option-inside-of-an-option thing is wrong.  Eliminate
the --exclude=' prefix and ' suffix.  Secondly, your include matches all
the things you're trying to exclude and comes before them, so none of
the excludes will have any effect.  Since including is the default, you
can just eliminate that option.  And finally, we need to know what
$srcdir is to know if your excludes are based properly.  If $srcdir is
/test/runs/, then your excludes need the dir prefixes removed:

--exclude='/?' --exclude='/??' --exclude='/???' --exclude='/1???'

If $srcdir is /test/runs (w/o the trailing slash) add in a "/runs"
prefix, etc.  (Absolute exclude names should always match the verbose
output with a prefixed slash to anchor it.)


More information about the rsync mailing list