Rsync – Transfer Files Between Two Remote Servers

rsync

I have 3 servers. Call them A, B, and C. B and C are remote and only have A in their hosts.allow.

What I need to do is log into A, and then rsync over SSH the files from B to C. I want to use rsync because many of the files are similarly present on both B and C.

I could try to rsync from B -> A and then from A -> C except I don't have nearly enough disk space on A, so I'd have to find some way of "chunking" the files and I don't see an obvious way of grouping them, and even if I did, I'd have to babysit it too much, with deleting files off A's disk, restarting the process with the next chunk etc.

So is it somehow possible for me to rsync between the two servers? I don't think I will be able to get anyone to change the hosts.allow for me 🙁

Best Answer

You should be able to set up an SSH tunnel from A->B and from A-C, and then rsync directly from B->C by going across that tunnel.

It's going to be a bit complicated, but basically you do the following:

  1. Set up an rsync daemon on a high port (say 20000) on B
  2. Set up a LocalForward A:20000 to B:20000 with ssh
  3. Set up a RemoteForward from C:20000 to A:20000 with ssh
  4. On C, rsync -av /path rsync://localhost:20000/path

Bear in mind that all this traffic will be going both in and out the network on A and being encrypted, so it will probably be pretty slow. it might be worth seeing if B is actually firewalled from C, you might be able to run the rsync server on a high port and connect directly.