Tuesday, 7 January 2014

rsync command in Linux

Goal: Sync between two directories in local or remote machine 

Solution:
 
mkdir -p mkdir test_sync

mkdir -p mkdir test1_sync


Copy/Sync a Directory on Local Computer

[root@tecmint]# rsync -avzh source destination

rsync -avzh /back/test_sync/ /back/test1_sync


Copy/Sync Files and Directory to or From a Server

rsync -avz /back/test_sync/ root@192.168.0.101:/back/test1_sync/

Copy/Sync a Remote Directory to a Local Machine

[root@tecmint]# rsync -avzh root@192.168.0.100:/back/test_sync/ /tmp/myrpms

Example 1. Synchronize Two Directories in a Local Server

To sync two directories in a local computer, use the following rsync -zvr command.

$ rsync -zvr /back/test_sync/ /back/test1_sync/
building file list ... done
sva.xml
svB.xml
.
sent 26385 bytes  received 1098 bytes  54966.00 bytes/sec
total size is 44867  speedup is 1.63
$

No comments:

Post a Comment