Home Explore Blog CI



man-pages

77th chunk of `rsync.man`
e409e6ce4b90b5cafca819a9792f1675f53d5c9b6eeff7170000000100001036
 lists.  This two‐sided de‐
       fault can be manually overridden so that you are only specifying  sender
       rules  or receiver rules, as described in the FILTER RULES IN DEPTH sec‐
       tion.

       When deleting, an exclude protects a file from being removed on the  re‐
       ceiving  side  while  an  include overrides that protection (putting the
       file at risk of deletion). The default is for a file to  be  at  risk --
       its safety depends on it matching a corresponding file from the sender.

       An  example  of  the  two‐sided exclude effect can be illustrated by the
       copying of a C development directory between 2 systems.   When  doing  a
       touch‐up  copy,  you might want to skip copying the built executable and
       the .o files (sender hide) so that the receiving side  can  build  their
       own  and  not  lose  any object files that are already correct (receiver
       protect).  For instance:

           rsync ‐ai ‐‐del ‐f’‐ *.o’ ‐f’‐ cmd’ src host:/dest/

       Note that using -f’-p *.o’ is even better than -f’- *.o’ if there  is  a
       chance  that the directory structure may have changed.  The "p" modifier
       is discussed in FILTER RULE MODIFIERS.

       One final note, if your shell doesn’t  mind  unexpanded  wildcards,  you
       could  simplify  the typing of the filter options by using an underscore
       in place of the  space  and  leaving  off  the  quotes.   For  instance,
       -f -_*.o -f -_cmd  (and similar) could be used instead of the filter op‐
       tions above.

   FILTER RULES IN DEPTH
       Rsync supports old‐style  include/exclude  rules  and  new‐style  filter
       rules.   The  older rules are specified using --include and --exclude as
       well as the --include‐from and --exclude‐from. These are limited in  be‐
       havior but they don’t require a "-" or "+" prefix.  An old‐style exclude
       rule  is  turned  into a "- name" filter rule (with no modifiers) and an
       old‐style include rule is turned into a "+ name" filter  rule  (with  no
       modifiers).

       Rsync  builds  an  ordered list of filter rules as specified on the com‐
       mand‐line and/or read‐in from files.  New style filter  rules  have  the
       following syntax:

           RULE [PATTERN_OR_FILENAME]
           RULE,MODIFIERS [PATTERN_OR_FILENAME]

       You  have  your  choice of using either short or long RULE names, as de‐
       scribed below.  If you use a short‐named rule, the  ’,’  separating  the
       RULE  from the MODIFIERS is optional.  The PATTERN or FILENAME that fol‐
       lows (when present) must come after either a single space or  an  under‐
       score (_). Any additional spaces and/or underscores are considered to be
       a part of the pattern name.  Here are the available rule prefixes:

       exclude, ’-’
              specifies an exclude pattern that (by default) is both a hide and
              a protect.

       include, ’+’
              specifies an include pattern that (by default) is both a show and
              a risk.

       merge, ’.’
              specifies a merge‐file on the client side to read for more rules.

       dir‐merge, ’:’
              specifies  a per‐directory merge‐file.  Using this kind of filter
              rule requires that you trust the sending side’s filter  checking,
              so  it has the side‐effect mentioned under the --trust‐sender op‐
              tion.

       hide, ’H’
              specifies a pattern for hiding files from the transfer.   Equiva‐
              lent  to a sender‐only exclude, so -f’H foo’ could also be speci‐
              fied as -f’-s foo’.

       show, ’S’
              files that match the pattern are  not  hidden.  Equivalent  to  a
              sender‐only  include,  so  -f’S foo’  could  also be specified as
              -f’+s foo’.

       protect, ’P’
              specifies a pattern for protecting files from deletion.   Equiva‐
             

Title: Rsync Filter Rules: Advanced Usage and Syntax
Summary
This chunk continues explaining rsync filter rules, elaborating on the two-sided effect of include and exclude rules, particularly in the context of deletion. It provides an example of copying a C development directory between systems and using `-f'-p *.o'` to better handle directory structure changes. It then differentiates between old-style include/exclude rules (using `--include` and `--exclude`) and new-style filter rules. It details the syntax for new-style filter rules, explaining the use of RULE prefixes (exclude, include, merge, dir-merge, hide, show, protect) and their corresponding short-named equivalents ('-', '+', '.', ':', 'H', 'S', 'P'). It also explains the use of the underscore character as an alternative to a space in filter options and mentions the `--trust-sender` option in relation to `dir-merge`.