rsync = Remote Sync
- This is a remote and local file synchronization tool.
- It uses an algorithm that minimizes the amount of data copied by only moving the portions of files that have changed.
- This is a very flexible network-enabled syncing tool.
- Due to its ubiquity on Linux and Unix-like systems and its popularity as a tool for system scripts, it is included on most Linux distributions by default.
- It’s faster than scp (Secure Copy) because rsync uses remote-update protocol which allows to transfer just the differences between two sets of files. First time, it copies the whole content of a file or a directory from source to destination but from next time, it copies only the changed blocks and bytes to the destination.
- Rsync consumes less bandwidth as it uses compression and decompression method while sending and receiving data both ends.
Options used with rsync command
-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
# yum install rsync
- Copy/Sync Files and Directory Locally on the same machine
[root@eduguru]# rsync -zvh dbbackup.tar /home/dbbackups/ Output: created directory /home/dbbackups dbbackup.tar sent 140.71M bytes received 310 bytes 30.27M bytes/sec total size is 160.18M speedup is 10.10
- Copy/Sync a directory from a local machine to a remote machine
[root@eduguru]# rsync -avz dbcackup/ email@example.com:/home/
- Copy/Sync a directory from remote machine to local machine
[root@eduguru]# rsync -avzh firstname.lastname@example.org:/home/dbbackup /home/dbcakup
- To Show Progress While Copy/Transferring Data with rsync
To show the progress while transferring the data from one machine to a different machine, we can use ‘–progress’ option for it. It displays the files and the time remaining to complete the transfer.
[root@eduguru]# rsync -avzhe ssh --progress dbbackup/ email@example.com:/root/backupFor any query or issue, feel free to discuss on http://discuss.eduguru.in