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/*
- /*
#!/usr/bin/perl
use strict;
use warnings;
# read in all of the paths to include
my @all;
while (<>) {
chomp;
push @all, glob;
}
my (%inc, %exc);
for (@all) {
my @parts = split m{/};
for (1..$#parts) {
# include every path component up to the end
# e.g.
# /abc
# /abc/def
# /abc/def/ghi
$inc{join "/", @parts[0..$_]}++;
# exclude every other path component
# e.g.
# /abc/def/*
# /abc/*
# /*
$exc{join "/", @parts[0..$_-1]}++;
}
}
# include things from shortest-to-longest path
# exclude things from longest to shortest
print "+ $_\n" for sort keys %inc;
print "- $_/*\n" for reverse sort keys %exc;
--
Please use reply-all for most replies to avoid omitting the mailing list.
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html