bash script: move large LV to another machine

Ed Heron <[email protected]> Wed, 14 Sep 2011 10:11:59 -0600
Newsgroups gmane.org.user-groups.nmlug
Message-ID <[email protected]>
  I've copied part of a large (100G) logical volume from one virtual
machine server to another, but it broke.  I'm looking for a way to
verify it copied and complete the copy in a way that would survive
another interruption.  rsync is cool, but doesn't work on devices.

  Prior to running this script, I generated a ssh key and copied it to
the remote machine to enable automatic ssh login.

  This isn't working.  Can anybody see why?  I suspect the last dd
command, but I'm not seeing what is wrong.

src_dev='/dev/vg/lv'
dst_addr='192.168.1.2'
dst_dev='/dev/vg/lv'
# sync_bs is the size of my logical extents
sync_bs='32M'
# dev_size is number of logical extents
dev_size='3200'

skip=0
while [ $skip -lt $dev_size ]
 do
  echo -n " $skip"
  src_md5=`dd if=$src_dev bs=$sync_bs skip=$skip count=1 2>/dev/null |
md5sum`
  dst_md5=`ssh $dst_addr "dd if=$dst_dev bs=$sync_bs skip=$skip count=1
2>/dev/null | md5sum"`
  if [ "$src_md5" == "$dst_md5" ]
   then
    # this block matches, move to next block
    echo -n "+"
    let seek=seek+1
   else
    # this block doesn't match, so send.  don't increment so we test.
    echo -n "-"
    dd if=$src_dev bs=$sync_bs skip=$skip count=1 2>/dev/null | ssh
$dst_addr "dd of=$dst_dev bs=$sync_bs skip=$skip 2>/dev/null"
  fi
 done


_______________________________________________
NMLUG mailing list
[email protected]
http://lists.b9.com/cgi-bin/mailman/listinfo/nmlug