rsync
has various options for reading various config from files so that you don't have to chain a bunch of individual --include
or --exclude
options together. All of these options (as far as I cantell) read from a file on your local computer:
--exclude-from=FILE
--include-from=FILE
--files-from=FILE
The doc for --files-from=FILE
even clarifies that you can use it with either a local or remote FILE:
In addition, the –files-from file can be read from the remote host instead of the local host if you specify a "host:" in
front of the file (the host must match one end of the transfer). As a
short-cut, you can specify just a prefix of ":" to mean "use the
remote end of the transfer".
What I'm wondering is where or what is the equivalent for --filter
? We have --include
and --include-from
; --exclude
and --exclude-from
. But where's --filter-from
? (Or what's the closest equivalent to it?)
The section on INCLUDE/EXCLUDE PATTERN RULES gives examples of using a list of pattern rules as if they were included in a file…
+ /some/
+ /some/path/
+ /some/path/this-file-is-found
+ /file-also-included
- *
but the only mention I could find of using them in a file is with a file loaded from a merge
or dir-merge
:
merge, . specifies a merge-file to read for more rules.
dir-merge, : specifies a per-directory merge-file.
I couldn't find any mention of whether that refers to a merge-file on the local or remote hosts, but from what I've tried so far, it seems to only work with a file on the remote host.
Best Answer
That's exactly the option:
(Note how
-F
is an alias to--filter "dir-merge /.rsync-filter"
.)merge
files are read from the local (client) system (unless you explicitly pass the option to the server using-M
). If the source is remote, all filter rules are automatically sent to it.Meanwhile
dir-merge
is always applied to the source, whether local or not. (Manual page: "These per-directory rule files must be created on the sending side because it is the sending side that is being scanned for the available files to transfer.")