rsync include / exclude

Michael C. Davis mcdavis941 at knology.net
Fri May 7 00:47:05 GMT 2004


At 04:50 PM 5/6/04 -0700, Wayne Davison wrote:
>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!]

Inconceivable!  OK, guilty as charged.  I started looking at rsync two days
ago.

>
>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.
>

Yes, I see I should have been more careful of the Rules of Unusual
Significance (R.O.U.S.'s).  Your explanation and the man page on the Samba
site make it clear that if a parent directory is excluded, then all of its
descendents are also excluded.  The man page I'd been looking at pertained
to an older rsync version and was less explicit about how include/exclude
works.  ("That rule you keep using ... I don'ta think it means what you
think it means.")

Anybody want a peanut?


More information about the rsync mailing list