Global rsync
filter rules beginning with a leading /
are anchored to the root of transfer. Quoting from the "INCLUDE/EXCLUDE PATTERN RULES" section of the man page:
if the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files, otherwise it is matched against the end of the pathname. This is similar to a leading ^ in regular expressions. Thus "/foo" would match a name of "foo" at either the "root of the transfer" (for a global rule) or in the merge-file's directory (for a per-directory rule).
In your command (rsync ... -arv /home/ben home-ben/
), the file /home/ben/foo
would be transferred to home-ben/ben/foo
. The root of transfer is home-ben
and the correct filter path is /ben/foo
. Thus,
- to match
/home/ben/.ccache
you need a filter path of /ben/.ccache
- to match
/home/ben/build/
you need a filter path of /ben/build/
A more detailed explanation can be found in the "ANCHORING INCLUDE/EXCLUDE PATTERNS" section of the rsync(1)
man page.
Note that simply leaving out the leading /
is not necessarily what you want. Quoting again from the same man page section:
An unqualified "foo" would match a name of "foo" anywhere in the tree because the algorithm is applied recursively from the top down; it behaves as if each path component gets a turn at being the end of the filename. Even the unanchored "sub/foo" would match at any point in the hierarchy where a "foo" was found within a directory named "sub". See the section on ANCHORING INCLUDE/EXCLUDE PATTERNS for a full discussion of how to specify a pattern that matches at the root of the transfer.
Thus a filter pattern of build/
would match a build directory anywhere in /home/ben
, even /home/ben/many/sub/directories/build/
.
--exclude={'landing','studio'}
and I had a space after the,
. The list must not contain any spaces.