I have multiple source dirs, say /home/me/source1
and /mnt/somedisk/source2
. I want to push them both to something like /home/someoneelse/dest1
and /home/someoneelse/dest
respectively. I'd like to use one rsync command to this, is this possible?
What about for N directories to N directories where every directory is uniqe?
If you're doing this frequently, I'd also suggest handling this through scripting.
If the destination root is always the same, such as:
rsync /foo/blah1 /bar/
andrsync /fin/blah2 /bar/
You can handle that with a simple Bash for loop.
And for that matter, you can also set up nested loops so that various sources can go to each destination. We've used that as our basic backup system at our office for years now.
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
andsource2
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) andhome/me/source1
would be a symlink to/home/someoneelse/dest1
. When not using--keep-dirlinks
, then you should not transfersource1
itself (as that would delete the symlink and replace it with a directory), but instead all the files insidesource1
, i.e./home/me/source1/*
. Useshopt -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.