Excluding most and including some problems continue.

Benjamin R. Haskell rsync at benizi.com
Fri Oct 1 14:28:56 MDT 2010


On Fri, 1 Oct 2010, Wayne Davison wrote:

> On Thu, Sep 30, 2010 at 8:27 AM, Ian Skinner wrote:
>
>> Unfortunately there are some subdirectories in some of these selected 
>> */htdocs/docs* directories that are unintentionally being excluded by 
>> these rules.  I.E. */export/home/enf/htdocs/docs/county/internal/*.
>
>
> It is usually best to anchor your matching terms, unless you want a 
> term to float and match anywhere.  In an .rsync-filter file, terms 
> that start with a slash are anchored in that file's directory.  You 
> can also use a wildcard for all the subdir excusions.  For example:
>
>
> + /das
> + /em
> + /enf
> + /internal
> + /itb
> + /medtox
> + /pml
> + /psb
> + /reg
> + /whs
> - /*
>
> + /*/htdocs
> - /*/*
>
> + /*/htdocs/docs
> - /*/htdocs/*
>
> Another alternative is to sprinkle .rsync-filter files throughout your 
> hierarchy with localized rules for that part of the hierarchy, but the 
> above should do what you want.
>

I think I sent a variant of the attached Perl script last time someone 
was asking something similar.  What Wayne suggested is better right now 
(that is: while your patterns are very simple -- just a few root-level 
directories, each of which should include the /htdocs/docs/ subdir). 
But if you start adding more, it could get more annoying to have to 
manually fiddle with the rules.

The attached script takes as input lines of the form:
/rooted/path/to/include

and produces what should work as a filter file. It supports 
'{one,other}' brace-style expansions (but I think that may be 
OS-dependent -- I think it works if your system's 'glob()' function 
supports them).  So, for example, I produced a working filter file for 
your situation from:

{==> input.rsync.rules <==}

/{das,em,enf,internal,itb,medtox,pml,psb,reg,whs}/htdocs/docs

{=========================}

$ perl ./rsync-filter-generate.pl input.rsync.rules
[produces rule file] [1]

$ perl ./rsync-filter-generate.pl input.rsync.rules | rsync --include-from=- /path/to/root/
[shows what would be transferred]

$ perl ./rsync-filter-generate.pl input.rsync.rules | rsync --include-from=- /path/to/root/ /path/to/dest/
[does it]


The general strategy:
$ echo /abc/def/ghi | perl ./rsync-filter-generate.pl
+ /abc               -- first include each path component
+ /abc/def           -- one-at-a-time, for each thing to include
+ /abc/def/ghi
- /abc/def/*         -- then exclude everything else at each
- /abc/*             -- level of the hierarchy
- /*

-- 
Best,
Ben

[1] output for your case:

+ /das
+ /das/htdocs
+ /das/htdocs/docs
+ /das/htdocs/other
+ /em
+ /em/htdocs
+ /em/htdocs/docs
+ /enf
+ /enf/htdocs
+ /enf/htdocs/docs
+ /internal
+ /internal/htdocs
+ /internal/htdocs/docs
+ /itb
+ /itb/htdocs
+ /itb/htdocs/docs
+ /medtox
+ /medtox/htdocs
+ /medtox/htdocs/docs
+ /pml
+ /pml/htdocs
+ /pml/htdocs/docs
+ /psb
+ /psb/htdocs
+ /psb/htdocs/docs
+ /reg
+ /reg/htdocs
+ /reg/htdocs/docs
+ /whs
+ /whs/htdocs
+ /whs/htdocs/docs
- /whs/htdocs/*
- /whs/*
- /reg/htdocs/*
- /reg/*
- /psb/htdocs/*
- /psb/*
- /pml/htdocs/*
- /pml/*
- /medtox/htdocs/*
- /medtox/*
- /itb/htdocs/*
- /itb/*
- /internal/htdocs/*
- /internal/*
- /enf/htdocs/*
- /enf/*
- /em/htdocs/*
- /em/*
- /das/htdocs/*
- /das/*
- /*
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rsync-filter-generate.pl
Type: text/x-perl
Size: 666 bytes
Desc: 
URL: <http://lists.samba.org/pipermail/rsync/attachments/20101001/6311c9bf/attachment.pl>


More information about the rsync mailing list