0

I maintain a directory structure containing dirs and files that I regularly push to ~50 hosts, which are divided into 3 groups that have slightly different needs - minor mods in a couple of files.

So ideally I would have 4 directories:

/path/to/sync/common/   <- common files
/path/to/sync/group1/   <- group1 specific only
/path/to/sync/group2/   <- group2 specific only
/path/to/sync/group3/   <- group3 specific only

Then I'd run an rsync like

rsync -av --overlay /path/to/sync/groupN /path/to/sync/common remotehost:

Thinking in terms of a list of files to be transferred, I would like:

  • anything present in common/ added to the file list; then
  • anything present in groupN/ added to the list, clobbering anything already there

I realise I could populate the list myself and use --files-from=<LIST> but I would rather have rsync work it out if possible. I can't think of a simple way to populate the list myself that isn't clunky (second prize for pointing one out!)

1
  • 3
    Calling it an overlay is a actually pretty relevant keyword: overlayfs has been in the Linux kernel since v3.18. You could mount an overlayfs that provides a merged view on multiple directories like this: mount overlay /mnt/foo -t overlay -o lower=/path/to/group1:/path/to/common (double-check the syntax and read the relevant part of the kernel docs directory; I'm typing this from memory)
    – n.st
    Mar 31, 2016 at 7:17

1 Answer 1

0

I've figured out a way to do this that will work, by merging the trees locally first.

TEMPDIR=$(mktemp -d)
cp -r /path/to/sync/common/* $TEMPDIR
cp -r -f /path/to/sync/groupN/* $TEMPDIR
rsync -av $TEMPDIR/* remotehost:
rm -r $TEMPDIR

I'd still prefer to do it with rsync though, to say on local cp'ing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.