Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to synchronize two linux server 1

Status
Not open for further replies.

alan123

MIS
Oct 17, 2002
149
US
hi,

I have two identical redhat 8 servers(for web server), I try to synchronize these two machines to keep web document files same as the other one. how can I do that?
I have no idea how to use "rsync-2.5.5-1.i386", can anyone help me? many thanks.
 
You want to use Rsync, glad you find that out.

Here are some links to help you determine how you want to implement Rsync in your situation (SSH secured, openly rsync)


Here's a script I'm pretty proud of. It relies on you exchanging a key with the source server (see SSH articles above). Then you invoke this script on a cron'd schedule.
Adjust directories to suit your needs.

What is particularly key about this invocation of rsync is that it is going to preserve the source file tree (folder hierarchy) when it writes into the current directory (the "." at the end of the line). It deletes on the destination those files/folders that no longer appear on the source. In short, it perfectly duplicates files and folders. I DID NOT pay a great deal of attention to file timestamps nor permissions retention, I'll leave that to you..... I have logging enabled for my own reasons, mainly to keep cron happy.

The first time you run this will take the most time. Afterwards, it should quickly slip into "incremental" maintenance of the sync and you should't have a great deal of time spent making the sync.

====filename: backup_web.example.com.sh===============
#!/bin/sh
HOSTNAME="web.example.com"
cd /var/backup/$HOSTNAME

WORKLOG="/var/log/backup.work.log"
ERRLOG="/var/log/backup.err.log"

echo $0 >> $WORKLOG
date 1>> $WORKLOG
echo $0 >> $ERRLOG
date 1>> $ERRLOG

rsync -Rtav --rsh=ssh --delete root@$HOSTNAME:/usr/local/apache/htdocs . 1>>$WORKLOG 2>>$ERRLOG
================================================



"Surfinbox Shares" - A fundraising program that builds revenue from dialup Internet users.
 
You could also use a replicating file system, such as InterMezzo, which would give you identical copies at all times.

//Daniel
 
I tried to use rsync to synchronize two servers, but when I use command "rsync user@host:/path to folder/ /dest folder/", each time I have to manually enter password, it's impossible to run at crond, can I add password in rsync command line so it won't prompt again?

thanks.
 
You obviously did not read and implement the information "thedaver" pointed you at?


This shows you how to set up private/public key exchange without a passphrase.

That will resolve your issue.

Good Luck,
Laurie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top