rsync include / exclude

Wayne Davison wayned at samba.org
Thu May 6 23:50:00 GMT 2004


On Thu, May 06, 2004 at 01:20:34PM -0500, Michael C. Davis wrote:
> I've narrowed it down to a test script for a representative case
> which, again, should be working but isn't.

You fell victim to one of the classic blunders!  The most famous of
which is, "Never get involved in a land war in Asia."  But only slightly
less well known is this: "Never exclude '*', when death is on the line!"
Ha ha ha ha ha!  Ha ha ha ha!  [Clunk!]

Here's a serious answer:

Always include ALL the parent dirs when excluding '*'.  Also, consider
using a less powerful trailing exclusion.  In the following example,
I've put the include and exclude rules into a single file named "excl":

% cat excl
+ /usr/
- /*
+ /usr/etc/
- /usr/*

% rsync -aHvn ... --exclude-from=excl $SRC $DEST

Or:

% cat excl
+ /usr/
+ /usr/etc/
+ /usr/etc/**
- *

Note that the last two includes in the latter example are both
necessary, as the last one only includes what's inside the
directory, but not the directory itself.

..wayne..


More information about the rsync mailing list