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/ firstname.lastname@example.org:/home/
- Copy/Sync a directory from remote machine to local machine
[root@eduguru]# rsync -avzh email@example.com:/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/ firstname.lastname@example.org:/root/backup
- 56cd : Change Directory The cd command, which stands for "change directory", changes the shell's current working directory. It is a builtin command, which means that it is executed directly by your shell, instead of launching an external program. cd is a command-line OS shell commandused to change the current working directory…
- 54Welcome to the Linux Knowledge Base and Tutorial so you want to learn how to use the Bash command line interface (terminal) on Unix/Linux. Or, it's part of a subject you're doing and so you're learning it because you have to. Either way, that's great. You're learning how to use…
- 51What is a process? Except the kernel, Everything on a Linux system runs in the context of a process. Process can be loosely defined as a running program. Every process on a Linux system has a unique Process ID (PID). Users and programs use this PID to communicate with the…