4

I'm about to start a big rsync between two servers on my LAN. Is it better for me to push the files from one server to the other or pull them (backwards)?

There is not anything that would make one work, and the other not work -- I am just wondering if there is a reason (maybe speed) to do one over the other.

Can anyone give me a good reason, or is there no reason to do one over the other?

1
  • 7
    If there's a reason, it won't be speed; the bottleneck is the network.
    – goldilocks
    Jul 31, 2014 at 20:52

4 Answers 4

9

The way rsync algorithm works can be found from here.

The algorithm identifies parts of the source file which are identical to some part of the destination file, and only sends those parts which cannot be matched in this way. Effectively, the algorithm computes a set of differences without having both files on the same machine. The algorithm works best when the files are similar, but will also function correctly and reasonably efficiently when the files are quite different.

So it would not make a difference whether you are uploading or downloading as the algorithm works on checksums of the source and destination files. So, any file can be the source/destination.

I find some more useful information from here. Some of the excerpts are,

RSync is a remote file (or data) synchronization protocol. It allows you to synchronize files between two computers. By synchronize, I mean make sure that both copies of the file is the same. If there are any differences, RSync detects these differences, and sends across the differences, so the client or server can update their copy of the file, to make the copies the same.

RSync is capable of synchronizing files without sending the whole file across the network. In the implementation I've done, only data corresponding to about 2% of the total file size is exchanged, in addition to any new data in the file, of course. New data has to be sent across the wire, byte for byte.

Because of the way RSync works, it can also be used as an incremental download / upload protocol, allowing you to upload or download a file over many sessions. If the current upload or download fails, you can just resume it later.

1
  • I completely forgot that I hadn't accepted this one :D... Oct 25, 2016 at 13:33
3

The rsync program actually runs a copy of itself on the remote server. Once rsync is running on both ends, they negotiate between themselves how to best transfer the requested files. I don't think it matters which one is started first.

However, I would usually initiate the transfer from the machine that is closest to me. That way, if something goes wrong I am more likely to be able to monitor the file transfer progress. If both machines are on the same LAN, then this reason wouldn't be a reason to pick one over the other.

1

Push or Pull method can be significant if the transfer uses an ADSL line because bitrates are different when you download or when you upload. In such case, the choice depends on the location of the target machine.

1
  • 3
    Except that it won't matter -- if he's going to synchronize system A and system B, the entire delta from A to B will have to go over the line. Much in the same way, running scp foo.txt b: on A and scp a:foo.txt ./ on B should take exactly the same time, barring misconfiguration on either server. Sep 3, 2017 at 19:30
1

With regards to security and backup for public-facing servers, it is usually better to pull than to push from the data backup source. For example, if the data source becomes compromised in anyway (from hacking), it will expose the credentials to its backup server. Also pulling instead of pushing isolates the backup process to the backup server, rather than having to maintain backup service on each individual backup source. It probably makes backup management easier. I imagine one backup server pulling backups from multiple sources and all the backup management would be done on a single server.

However, if it is for doing backups which are not mission critical, I'd prefer push for its simplicity and ease of use. I use push for all rsync-based backups at home for my personal data (via SFTP/SSH).

3
  • 1
    The reverse is true too, if using pull: If the backup server is compromised, it's likely that the credentials for all systems that uses that backup server are compromised as well. In fact, this may be worse than the other way around.
    – Kusalananda
    Jun 11, 2019 at 17:43
  • 1
    "With regards to security and backup for public-facing servers, it is usually better to pull than to push" Not at all, it would even be worse than the other way around.
    – Paradox
    Nov 1, 2019 at 16:49
  • Pulling is much better than pushing for security, as long as the backup server uses restricted credentials.
    – simon
    May 13, 2021 at 23:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .