/dest/dir
The first two commands above will look for ".rsync‐filter" in "/" and
"/src" before the normal scan begins looking for the file in "/src/path"
and its subdirectories. The last command avoids the parent‐dir scan and
only looks for the ".rsync‐filter" files in each directory that is a
part of the transfer.
If you want to include the contents of a ".cvsignore" in your patterns,
you should use the rule ":C", which creates a dir‐merge of the .cvsig‐
nore file, but parsed in a CVS‐compatible manner. You can use this to
affect where the --cvs‐exclude (-C) option’s inclusion of the per‐direc‐
tory .cvsignore file gets placed into your rules by putting the ":C"
wherever you like in your filter rules. Without this, rsync would add
the dir‐merge rule for the .cvsignore file at the end of all your other
rules (giving it a lower priority than your command‐line rules). For
example:
cat <<EOT | rsync ‐avC ‐‐filter=’. ‐’ a/ b
+ foo.o
:C
‐ *.old
EOT
rsync ‐avC ‐‐include=foo.o ‐f :C ‐‐exclude=’*.old’ a/ b
Both of the above rsync commands are identical. Each one will merge all
the per‐directory .cvsignore rules in the middle of the list rather than
at the end. This allows their dir‐specific rules to supersede the rules
that follow the :C instead of being subservient to all your rules. To
affect the other CVS exclude rules (i.e. the default list of exclusions,
the contents of $HOME/.cvsignore, and the value of $CVSIGNORE) you
should omit the -C command‐line option and instead insert a "-C" rule
into your filter rules; e.g. "--filter=-C".
LIST‐CLEARING FILTER RULE
You can clear the current include/exclude list by using the "!" filter
rule (as introduced in the FILTER RULES section above). The "current"
list is either the global list of rules (if the rule is encountered
while parsing the filter options) or a set of per‐directory rules (which
are inherited in their own sub‐list, so a subdirectory can use this to
clear out the parent’s rules).
ANCHORING INCLUDE/EXCLUDE PATTERNS
As mentioned earlier, global include/exclude patterns are anchored at
the "root of the transfer" (as opposed to per‐directory patterns, which
are anchored at the merge‐file’s directory). If you think of the trans‐
fer as a subtree of names that are being sent from sender to receiver,
the transfer‐root is where the tree starts to be duplicated in the des‐
tination directory. This root governs where patterns that start with a
/ match.
Because the matching is relative to the transfer‐root, changing the
trailing slash on a source path or changing your use of the --relative
option affects the path you need to use in your matching (in addition to
changing how much of the file tree is duplicated on the destination
host). The following examples demonstrate this.
Let’s say that we want to match two source files, one with an absolute
path of "/home/me/foo/bar", and one with a path of "/home/you/bar/baz".
Here is how the various command choices differ for a 2‐source transfer:
Example cmd: rsync ‐a /home/me /home/you /dest
+/‐ pattern: /me/foo/bar
+/‐ pattern: /you/bar/baz
Target file: /dest/me/foo/bar
Target file: /dest/you/bar/baz
Example cmd: rsync ‐a /home/me/ /home/you/ /dest
+/‐ pattern: /foo/bar (note missing "me")
+/‐ pattern: /bar/baz (note missing "you")
Target file: /dest/foo/bar
Target file: /dest/bar/baz
Example cmd: rsync ‐a ‐‐relative /home/me/ /home/you /dest