rsync : Linux Command

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

Installing rsync

# yum install rsync

Examples:

  • 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/ root@172.16.60.12:/home/

  • Copy/Sync a directory from remote machine to local machine

[root@eduguru]# rsync -avzh root@172.16.60.12:/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/ root@172.16.60.12:/root/backup

Related Posts

  • 64
    Use the blow command to set the linux date #date 072511242014 where 07= mm (Month) 25=dd (Date) 11=hh (Hour) 24=mm (minute) 2014=yyyy (Year)
    Tags: linux, command, time
  • 63
    What is rsync command in Unix based system? - Rsync, which stands for "remote sync", 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. - Rsync is a widely-used utility…
    Tags: rsync, remote, file, files, command, tool
  • 56
    cd : 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…
    Tags: directory, command, linux
  • 54
    Welcome 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…
    Tags: linux, files, file, data, command
  • 51
    What 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…
    Tags: linux, command

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: