how to mirror only selected directories?

Moe, Mark mark.moe at medtronic.com
Mon Aug 29 21:41:31 GMT 2005


Hi Aaron,

That's close!  But I can't have that particular side-affect since I'd
like to have one site be the master for all folders except for "abc"
folders and the 2nd site be the master for only the "abc" folders in
this particular tree.

Since what you mention works like you said, I was thinking something
like this should work too, but it doesn't:

  --include 'abc/**' --include '**/abc/' --exclude '*'

I have a work-around right now using a find/perl command line to build a
rsync commands for each "abc" folder, but I was hoping to have it all in
one rsync command if possible.

Thanks,

- Mark

-----Original Message-----
From: Aaron Morris [mailto:aaronwmorris at gmail.com] 
Sent: Monday, August 29, 2005 4:24 PM
To: Moe, Mark
Subject: Re: how to mirror only selected directories?

On 8/29/05, Moe, Mark <mark.moe at medtronic.com> wrote:
> Hi,
> 
> I've tried various combinations of --exclude and --include, but I
can't
> quite get it.  What I'd like to do is only mirror certain directories
in
> a tree.  For example, say a directory tree starting at /x contained
> under it several directories named "abc".  I want to mirror only the
> "abc" directories and what's under them and nothing else.
> 
> /x/abcdef/456
> /x/y/z
> /x/y/abc/123
> /x/z/123
> /x/z/abc/456
> 
> If the above represents the 5 files under /x, then I'd like to rsync
to
> only mirror the files under "abc" folders, namely /x/y/abc/ and
> /x/z/abc/.  I tried to include '*/abc/*' and exclude '*', but that
> didn't work.
> 
> Thanks,
> 
> - Mark

The only way I know of to do this is to include all directories, but
only include the contents of the directories you want.  This will have
the side-effect of replicating the full directory structure, but you
may be able to live with that.

--include "abc/*" --include "*/" --exclude "*"
(or --include "abc/**" if you want contents of abc's sub-directories)

-- 
Aaron W Morris (decep) <aaronwmorris at gmail.com>


More information about the rsync mailing list