One critical thing to add:  you need to run one of the dd processes through an rsh, 
ssh, krsh, something like that, in both the check and the transfer.  I'd probably also 
feed the transfers through a fast gzip, for the network's sake, and I think I'd 
look for an "finished" condition.  Maybe do an initial dd to /dev/null, to check how 
many blocks there will be,
blocks=`dd if=$src bs=$blocksize of=/dev/null 2>&1 |sed -n '/records 
in/s/\([0-9]*\)+\([0-9]*\) .*$/\1 + \2/p'`
blocks=`expr $blocks`
should get it .
you can do it in a one-liner with ksh
blocks=$(expr $(dd if=$src bs=$blocksize of=/dev/null 2>&1 |sed -n '/records 
in/s/\([0-9]*\)+\([0-9]*\) .*$/\1 + \2/p'))

Then, instead of true, i'd use [ "$blocks" -ge "$count" ]
I'd probably also have it listing the current and destination blocks as it goes, just 
for my own sanity.

We've sure put a lot into this single case, haven't we?

Tim Conway
[EMAIL PROTECTED]
303.682.4917
Philips Semiconductor - Colorado TC
1880 Industrial Circle
Suite D
Longmont, CO 80501




[EMAIL PROTECTED] on 04/13/2001 05:36:38 PM
Please respond to [EMAIL PROTECTED]@SMTP
To:     Tim Conway/LMT/SC/PHILIPS@AMEC
cc:     [EMAIL PROTECTED]@SMTP 
Subject:        Re: rsync between partitions
Classification: 


"A month of sundays ago [EMAIL PROTECTED] wrote:"
> Actually, I've got one for you, though.  Since there are no insertions, you can use 
>dd on both ends, through rsh (or ssh).  use it with skip, seek, conv=notrunc, 
>count=1, and some appropriate block size (the block size of the filesystems, maybe?), 
>and
> the sum command.  get the sum on the master with a count=1, skip=whatever, then the 
>replica.  If they're different, send the master to the replica with seek and 
>conv=notrunc.  Make sure you do the dd AND the sum all on the remote, so all you pull 
>back
> are the checksums.  You can do this in a shell script, which would be easier than 
>hacking rsync (use an advanced shell (bash,ksh), or perl, as since you need to do 
>this, i reckon the numbers could get big.


essentially this, plus ssh.

Best to start a server application, though.


src=$1
dst=$2

blksiz=`expr 64 \* 1024`

count=0
while true; do
  srcsum=`dd if=$src count=1 bs=$blksiz skip=$count | md5sum`
  dstsum=`dd if=$dst count=1 bs=$blksiz skip=$count | md5sum`
  if [ $dstsum != $srcsum ]; then
    dd if=$src count=1 bs=$blksiz skip=$count | \
    dd of=$dst count=1 bs=$blksiz seek=$count conv=notrunc
  fi
  count=$[ $count + 1 ]
done


Peter






Reply via email to