If you don't have to copy any symbolic links, then you can set up a directory on the receiving side which mimics the directories layout on the sending side, each link pointing at the intended destination.
One single approach would be having symlinks source1
and source2
on the receiving side, and to run the receiving process with --keep-dirlinks
.
If you have to transfer symlinks, then you might make --no-implied-dirs
work for you. Again you'd have symlinks on the receiving side, but this time inside a directory structure, i.e. home/me/
would be directories (inside the rsync destination folder, wherever you want that to be) and home/me/source1
would be a symlink to /home/someoneelse/dest1
. When not using --keep-dirlinks
, then you should not transfer source1
itself (as that would delete the symlink and replace it with a directory), but instead all the files inside source1
, i.e. /home/me/source1/*
. Use shopt -s dotglob
to match hidden files in that as well.
All of this is only remotely tested: I know I had something along these lines working at some time, but don't have details or commands available just now. So test possible combinations, in particular changes between directories and symlinks to directories, before using this in a production setup.