Linux – rsync multiple source directories to multiple dest directories

linuxrsync

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?

Best Answer

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/ and rsync /fin/blah2 /bar/

You can handle that with a simple Bash for loop.

for x in /foo/blah1 /fin/blah2
do
    rsync $x /bar
done

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.