How to rsync selective subdirectories

Wayne Davison wayned at users.sourceforge.net
Mon Aug 12 08:20:40 EST 2002


On Mon, 12 Aug 2002, Nitin Agarwal wrote:
> I want to rsync all the dates directories but only the "toid"
> subdirectory.

The easiest thing to do might be to use the -R (--relative) option, like
this:

    rsync -avR /abc/dir/*/toid host:/dest/

This will create the /abc/dir/DATE/toid dirs on the destination side.
If the "/dest/" dir begins with "/abc/dir", that part will be skipped.

If you don't like the extra subdirs, use an include file like this:

+ /*/toid
- /*/*

and a command like this:

    rsync -avR --include-from=above-file /abc/dir/ host:/dest/

This includes everything in the base dir (by default), and only the toid
dirs in the one-level-deep subdirs.  All other files are unaffected.
So, if the date dirs aren't the only thing in the base dir, you'll need
a more complicated include file, like this:

+ /[1-2][0-9][0-9][0-9][0-1][0-9][0-3][0-9]
- /*
+ /*/toid
- /*/*

..wayne..




More information about the rsync mailing list