Rsync to multiple directories with one command?

Perhaps use a for loop:

for dest in dest1 dest2; do 
    rsync -av --exclude='.git' source $dest
done

The suggested for loop solution works, but if you're transferring a large amount of data, it will be very slow. This is because it serializes the jobs, which are bound by the speed of disk-write. A better but slightly more complex alternative is to use GNU Parallel:

http://www.gnu.org/software/parallel/

You can come up with a command to parallelize multiple rsync runs, which would be N times faster if you're writing to N disks at the same time.

A similar parallel solution for a network-bound problem is given here:

https://stackoverflow.com/questions/24058544/speed-up-rsync-with-simultaneous-concurrent-file-transfers

Tags:

Backup

Rsync