It is quite common that two servers may need to keep some data synchronized on a regular basis. You have a few options to do this, including File Transfer Protocol (FTP), Network File System (NFS), or scp. The problem with these protocols is that it is difficult to know whether files have changed since last synchronizing them — and even if they have, the full file still needs to be copied.
rsync is an effective transfer protocol that has been designed to deal with these issues. We have used it many times to take backups of data from one server to upgrade to another physical machine, and it proves very useful when dealing with many gigabytes of data that may change many times throughout the day. It is extremely efficient because it only sends data that differs between the two copies, so for network backups it is a good choice. However, rsync needs to be installed on both servers.
Another very good feature of rsync is the way you can compress the data stream that is sent from the server. This can help to reduce the amount of time it takes to synchronize data.
For example, rsync is great at keeping a web site synchronized to a local copy on one of our laptops — just in case the worst happens (see Listing 15-13).
Was this article helpful?