Link to home
Start Free TrialLog in
Avatar of usaperl
usaperl

asked on

how to sync two directories

Hi,
  I have two solaris 2.8 servers and want
to make sure two directories are
in sync between two servers.  Eventhough
both directories on two different servers
have same number of files and sizes,
du -ks /dir1 reports different size
on two servers.   Is there a uitlity out
there that allow me to make sure this two
directories are in sync...if not copy the new
change files.   rsh,rdist,rsync are not
allow...only ssh is open.


thanks
ASKER CERTIFIED SOLUTION
Avatar of automator
automator

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tintin
Tintin

I second the rsync suggestion.

Available from http://rsync.samba.org/
Hi!

What do you mean by having the dirs in sync ?
Is one of the dirs considered master and the other slave so the slave should always be an exact copy of the master.

Or is this because you know they should be exactly the same and the aren't and you just want to do a one time check that they are the same ?

If the above is true and you just want to find out which files are diffrent I suggest you start by using scp on one machine copying the dir to /tmp/[computer_name.dir_name] then copy the other dir to /tmp/[computer_name.dir_name]

Now you can do a shell script to do diff on all files or use cp with the only newer or changed files or use a mirror script/program to find out which files differ.

If you use cp, you can first copy one dir to the other then do the other way around so you find all files not exsisting in the other dir.

If you want master/slave dir sync done on a regular basis I suggest as you create a script doing an scp and putting that into crontab to run it every hour/ every 8 hours or whatever your needs are.

Regards
/Hans - Erik Skyttberg

heskyttberg.

rsync will do everything that you suggested in a very efficient way.
Hi!

Yes, Tintin, but he was forbidden to use rsync.
If you read the question it's stated at the bottom:
"   rsh,rdist,rsync are not
allow...only ssh is open."

Regards
/Hans - Erik Skyttberg
Yes, but if ssh is open on the firewall, then he *can* use rsync.  rsync can run over rsh/ssh or connect to a rsync daemon.  99% of people simply run it over ssh.
I second Tintin's "rsync" solution. You can download the binary package from:

http://sunfreeware.com/
>Comment from yuzh  02/09/2003 05:00PM PST  
>I second Tintin's "rsync" solution. You can download >the binary package from:
>
>http://sunfreeware.com/
 
Whose solution?

Almost everyones solution/suggestion.
Ahh, okay. I think I made the mistake of being the first to submit an rsync-over-ssh solution, spelling it out in nearly gory detail and assuming that I'd be credited with it. I'll just standby while someone else takes credit.

-phil
automator.

You were indeed the first to suggest rdist over ssh and it's just that a few of the other posters didn't read that correctly.

We need usaperl to come back and give you the points (if indeed they do ever respond)
Hi automator,

  The person who make a suggestion to use "rsync" in the first place should get credit for this question. Sorry, I didn't notice is YOU.

  rdisd, scp, rsh IS NOT the solution for this job.

  My initial intention is to let usaperl to make it his mind to use "rsync".

  I just try to help usaperl to get "rsync" for his system.

  Cheers!

PS: usaperl please DO NOT accept any of my comment as answer, thank you.
Avatar of usaperl

ASKER

thank you to all for your help and feedback.
I wish I can accept all comment as answers.
Avatar of usaperl

ASKER

I have lots of binary files in my directory,
use rsync takes forever...please advise
rsync uses a very efficient algorithm to only send updates, so it is surprising that you say it is taking forever.

Perhaps there are some other factors at work like network problems.

Try running rsync with the --verbose flag to get a better idea of where is it taking its time.
Tips for this one:

If you want to copy files from dir1 to an empty dir2, and then sync the two dirs in regular base.

use "tar with ssh" for the first time to do the job, then use rsync for sync the two dir in regular base.

and also check your mtu setting (ifconfig -a)

Avatar of usaperl

ASKER

good suggestions...thanks