Rsync is a unique, full-featured file transfer facility. It can perform differential uploads and downloads (synchronization) of files across the network, transferring only data that has changed.
- How does Rsync work?
- Rsync faster than scp or sftp?
- How to use Rsync to sync files between servers?
For example, if there is a local copy of a 50MB file and a newer version of the file on a remote system has only 1MB of differences, only the changed 1MB (along with minor overhead) is transferred between both systems.
Table of Contents
How does Rsync work?
Rsync, by default, finds files that need to be transferred using a “quick check” algorithm (by default) that looks for files that have changed in size or in last-modified time. Any changes in the other preserved attributes (as requested by options) are made on the destination file directly when the quick check indicates that the file’s data does not need to be updated.
Rsync faster than scp or sftp?
By transferring less data, rsync is considerably more useful when dealing with slow or small bandwidth network connections. However, it has no advantage over other file transfer protocols such as ftp or scp when copying new files between systems.
How to use Rsync to sync files between servers?
For copying a large amount of data from one server to another, rsync is the best choice.
rsync command can be run on any of the servers. Some common options used with rsync commands.
- -v : verbose
- -r : copies data recursively (but don’t preserve timestamps and permission while transferring data
- -a : archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships and timestamps
- -z : compress file data
- -h : human-readable, output numbers in a human-readable format
We usually use the following commands to transfer files in local and remote mode.
rsync -a /home /backups/
rsync -avz /home server:/backups/