Include and Exclude
wayned at samba.org
Fri Jun 17 05:43:55 GMT 2005
On Thu, Jun 16, 2005 at 10:00:07AM +0200, fRANz wrote:
> rsync -avzHP --include "3.4/" --include "3.4/**" --include "4.0/"
> --include "4.0/**" --exclude "*" --bwlimit=30
> rsync.example.foo::packages/centos/* .
An easier way to do this is to use:
--include=/3.4/ --include=/4.0/ --exclude='/*'
That anchors the dirs and the wildcard so that they only apply to the
root of the transfer (making the ** includes unnecessary). Also, you
are usually better off just using a trailing slash at the end of a
directory arg instead of specifying a '*' after it.
> I would like to rsync only dirs "xxx" and "yyy" from 3.4 and 4.0, for example:
> /packages/centos/3.4/someone/xxx/ - yes
> /packages/centos/3.4/someone/ - no
> /packages/centos/4.0/someone/xxx/ - yes
> /packages/centos/4.0/sometwo/yyy/ - yes
This works in a similar way to the example above -- specify what you
want to include at a particular level, and then exclude everything else
at that level. As long as the source arg contains "/packages/centos/",
your include/exclude rules would look like this (I'm switching to the
exclude file format):
Another solution might be to use --files-from combined with -r. Since
the --relative option gets turned on, the paths from the args gets used
in the destination. Put this in a file "mylist":
And then run this:
rsync -avzHPr --files-from=mylist --bwlimit=30 host::packages/centos/ .
More information about the rsync