3

Below are the directories of my directory structure.

I only want to run rsync on the content under the archive directory of any subdirectory and exclude everything else:

./
ap/
ap/aploader/
ap/aploader/archive/
ap/as400/
ap/as400/archive/
ce/
ce/archive/
edi/
edi/810/
edi/810/archive/
fin/
fin/adp/
fin/adp/archive/
gl/
gl/adp/
gl/adp/archive/
gl/as400/
gl/as400/archive/
gl/dcb/
gl/dcb/archive/
om/
om/pricelist/
om/pricelist/archive/
om/sygma/
om/sygma/archive/

The source and destination directories have the same directory structure but only archive directory need to rsync.

For example:

Everything under /xx/inbound/om/pricelist/archive needs to be copied to /yy/inbound/om/pricelist/archive and xx/inbound/om/sygma/archive needs to be copied to /yy/inbound/om/sygma/archive, and so on...

I tried the following which doesn't work as I want it to:

rsync --include '**archive/***' --exclude '*' -avzh -avzh /xx/inbound/ /yy/inbound
2
  • try replacing the order of the include and exclude, first exclude everything, then include only the archive folders.
    – Rabin
    Jul 16, 2014 at 20:16
  • Even that don't work Jul 16, 2014 at 20:29

1 Answer 1

4

I think the only thing you're missing is to initially include all directories leading to the archive dirs, ie. also --include='*/'. This is because excluding a directory (with '*') excludes everything below it

rsync --include='*/' --include='**archive/***' --exclude='*' -avzh /xx/inbound/ /yy/inbound

Apart from that, you shouldn't need 2 sets of '-avzh'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .