Thinking Out Loud

July 9, 2007

rsync is cool

Filed under: linux — mdinh @ 5:23 pm

I recommend using SSH with private and public key with rsync for simplicity.

http://www.ibm.com/developerworks/eserver/library/es-ssh/?ca=dgr-lnxw06ParallelCommandsWithSSH

Configuration:

Server 172.24.223.52 contains a shell script to add date to t.log when executed:

:/home/oracle$ cat t.sh
date >> t.log

Use rsync to synchronize files across servers:

:/home/oracle$ rsync -arvvz –delete-after –rsh=/usr/bin/ssh 172.24.223.52:/home/oracle/t.log /home/oracle/t2.log
opening connection using /usr/bin/ssh 172.24.223.52 rsync –server –sender -vvlogDtprz . /home/oracle/t.log
receiving file list …
[sender] expand file_list to 131072 bytes, did move
done
delta transmission enabled
/home/oracle/t2.log
total: matches=0  tag_hits=0  false_alarms=0 data=58

sent 36 bytes  received 267 bytes  606.00 bytes/sec
total size is 58  speedup is 0.19

Updated file:

:/home/oracle$ cat t2.log
Mon Jul  9 16:41:53 UTC 2007
Mon Jul  9 16:42:36 UTC 2007

Executing rsync again shows file is up to date:

:/home/oracle$ rsync -arvvz –delete-after –rsh=/usr/bin/ssh 172.24.223.52:/home/oracle/t.log /home/oracle/t2.log
opening connection using /usr/bin/ssh 172.24.223.52 rsync –server –sender -vvlogDtprz . /home/oracle/t.log
receiving file list …
[sender] expand file_list to 131072 bytes, did move
done
delta transmission enabled
/home/oracle/t2.log is uptodate
total: matches=0  tag_hits=0  false_alarms=0 data=0

sent 16 bytes  received 187 bytes  406.00 bytes/sec
total size is 58  speedup is 0.29

Execute shell script remotely:

:/home/oracle$ ssh 172.24.223.52 /home/oracle/t.sh

Synchronize file:

:/home/oracle$ rsync -arvvz –delete-after –rsh=/usr/bin/ssh 172.24.223.52:/home/oracle/t.log /home/oracle/t2.log
opening connection using /usr/bin/ssh 172.24.223.52 rsync –server –sender -vvlogDtprz . /home/oracle/t.log
receiving file list …
[sender] expand file_list to 131072 bytes, did move
done
delta transmission enabled
/home/oracle/t2.log
total: matches=0  tag_hits=0  false_alarms=0 data=87

sent 42 bytes  received 273 bytes  630.00 bytes/sec
total size is 87  speedup is 0.28

Updated file:

:/home/oracle$ cat t2.log
Mon Jul  9 16:41:53 UTC 2007
Mon Jul  9 16:42:36 UTC 2007
Mon Jul  9 16:43:04 UTC 2007

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: