views:

40

answers:

1

I have two separate physical servers PRIMARY and SECONDARY connected with a ethernet switch of 100 mbps and i want to rsync files from my PRIMARY /home to SECONDARY /home and now after working for two hours in my SECONDARY server i have created some data in /home and so i want again the rsync to transfer the new data back to PRIMARY server. I think rsync handles the original data and new data automatically by itself.

1.so my question is how do i use rsync to transfer my PRIMARY /home data to SECONDARY /home ?

2.And also how do i again use rync on my SECONDARY server to transfer my updated /home to PRIMARY /home (which has the old data).

I also want this to be automated so how do i write a bash script for this process. Help will be appreciated.

A: 

That's pretty easy to do using rsync over ssh, provided rsync is available on both PRIMARY and SECONDARY.

Let's say you're logged in to SECONDARY. To sync your home directory from PRIMARY to SECONDARY, do:

$ rsync --progress --stats --delete -aHrvxz PRIMARY:~/* ~

To sync your home directory back from SECONDARY to PRIMARY, do:

$ rsync --progress --stats --delete -aHrvxz ~/* PRIMARY:~

EDIT: If you're logged in to PRIMARY, reverse the logic. For instance, to sync your home directory from SECONDARY to PRIMARY, do:

$ rsync --progress --stats --delete -aHrvxz SECONDARY:~/* ~
Frédéric Hamidi