How to use RSYNC

Posted: May 26, 2011 in Linux-Scripts, Redhat
Tags:

How do I use rsync command?

if you would like to sync’d between www1 and www2(master) servers, type the following command on www1 server:rsync -avrR --links --rsh=/usr/bin/ssh WWW2:/var/html/ /var/htmlWhere,

  • -avrR : archive mode (a), verbose (v), recurse into directories (r), use relative path names (R) [ I did not use R in my scripts for simplicity ]
  • –links : copy symlinks as symlinks
  • –delete                delete files that dont exist on master
    –rsh=/usr/bin/ssh : Use to specify the remote shell ssh to use (secure copy).
  • WWW2:/var/html/ : WWW2 server IP address and path to synchronize to www1 server
  • /var/html : WWW1 server path

A sample shell script for same job

#/bin/bash

MASTER="10.90.0.33"
DIR="/u01/backups/WMS852/online/"
LDIR="/u04/wms852bkup/online"
SSH="/usr/bin/ssh"
rsync -avr --links --delete --rsh=$SSH $MASTER:$DIR $LDIR

Advertisements

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