Saturday, May 15, 2010

"rsync" configuration in Linux/Unix

What "rsync" can do ?

"rsync" can perform differential uploads and downloads (synchronization) of files across the network, transferring only data that has changed. The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection.

Hand's ON Practical :-

Recommended : Install "rsync" on both linux or unix machines. (only for redhat/fedora)
yum install rsync


Note: Always use rsync over ssh
Since rsync does not provide any security while transferring data it is recommended that you use rsync over ssh . This allows a secure remote connection. Now let us see some examples of rsync.
Task 1: Copy file from a local computer to a remote server. Copy file from "/data/office.tar.gz" to a remote server called "192.168.1.1"

$ rsync -v -e ssh
/data/office.tar.gz rohit@192.168.1.1:/home/nishith

Task 2: Copy file from a remote server to a local computer

Copy file "/home/nishith/data.txt" from a remote server "192.168.1.1" to a local computer "/tmp" directory:
$ rsync -v -e ssh nishith@192.168.1.1:/home/nishith/data.txt /tmp

Give Password:

Task: Synchronize a local directory with a remote directory

$ rsync -r -a -v -e "ssh -l nishith" --delete 192.168.1.1:/home/nishith/ /data

Task: Synchronize a remote directory with a local directory

$ rsync -r -a -v -e "ssh -l nishith" --delete /data 192.168.1.1:/home/nishith/

Task: Synchronize a local directory with a remote rsync server

$ rsync -r -a -v --delete rsync://192.168.1.1/data /home/nishith/

"rsync" command common options.

  • --delete : delete files that don't exist on sender (system)
  • -v : Verbose (try -vv for more detailed information)
  • -e "ssh options" : specify the ssh as remote shell
  • -a : archive mode
  • -r : recurse into directories
  • -z : compress file data



No comments:

Post a Comment