Getting --delete to work, simply

Mike Brown brown at
Thu May 3 20:06:14 UTC 2018

On Thu, May 03, 2018 at 02:59:11PM -0400, Kevin Korb via rsync wrote:
> Note that these are working because S* and s* are being applied to all
> the dirs and files within dirs.  So if you had x/Something it wouldn't
> get copied and if you had S/else it wouldn't get copied.  Maybe you want
> to add --prune-empty-dirs and an --include='*/' so that rsync will look
> inside of all dirs for matching files.

All not working so when when working with the next HDD backup:

rsync -vain --prune-empty-dirs --delete \
--include='[T-Z]*' --include='*/' --exclude='*' \
/share/Public/videos/ /share/Backup-HDD-05

When run without the --prune-empty-dirs it picked up a directory starting
with iZ, but didn't list the sub-directory and its files.  With the
--prune-empty-dirs, it was no longer listed.  It should never have been listed
in the first place as I never included "i".  But, worse than that, the
--include='*/' is causing ALL directories in /share/Public/videos/ to be
queued up for transfer to the backup HDD.

The filter rule is not working out in practice. For example, the following
directories do not get copied:


Why?  Because the "S" in Season is getting excluded because it is not in
the initial include rule.

How do you get the filter rule to only look at the first part of the path
and ignore the remaining part of the path?

The man page for Filter RULES has the following:

       As the list of files/directories to transfer  is  built,  rsync  checks
       each  name  to  be transferred against the list of include/exclude pat‐
       terns in turn, and the first matching pattern is acted on:  if it is an
       exclude pattern, then that file is skipped; if it is an include pattern
       then that filename is not skipped; if no  matching  pattern  is  found,
       then the filename is not skipped.

That tells me that the first rule I have "--include='[T-Z]*'" says that
Victoria/Season-1 and all its contents should be copied.  But, it is checking
again after the "/", thereby excluding the directory. :-(

Looking further at INCLUDE/EXCLUDE PATTERN RULES, I found the following:

       o      a trailing "dir_name/***" will match both the directory  (as  if
              "dir_name/"  had been specified) and everything in the directory
              (as if "dir_name/**" had been  specified).   This  behavior  was
              added in version 2.6.7.

So, changing "--include='[T-Z]*'" to "--include='[T-Z]*/***'" seems to have
done the trick (of course removing the "--include='*/'").

This has been a real brain teaser.

e-mail: vidiot at | vidiot at            /~\ The ASCII
        6082066843 at (140 char limit)       \ / Ribbon Campaign
Visit - URL:                           X  Against
                             / \ HTML Email
"What do you say Beckett. Wanna have a baby?" - Castle to Det. Beckett
"How long have I been gone?" Alexis after seeing Castle and Beckett w/ baby
 - Castle - 11/25/13

More information about the rsync mailing list