看到大家讨论好多system clone 的帖子,结合自己的实际写了这么一个script, 自动进行disk clone, 适用与4.0x的ufs 或advfs,
在我的DS10上运行通过。
大家有什么批评和建议,请不吝赐教
testbackup :
#!/bin/sh
# This script performs a disk-to-disk clone for backing up LMC alphastation DS10 system
# disks running either 4.0D or 4.0G
# Usage : # testbackup
# Author : Qing Zhu
# Date : Mar 19, 2004
echo
echo "***** System backup procedure invoked *******"
echo
# version check
echo -n "Checking OS version ... "
version=`sizer -v |awk '{print $3}'`
echo "done"
# Check device name of the system disk
echo -n "Checking current system disk ... "
if [ "$version" = "V4.0D" ]; then
current_hd=`df | grep -w "\/" | cut -c6-8`
fi
if [ "$version" = "V4.0G" ]; then
current_hd=`ls -al /etc/fdmns/root_domain | awk '{print $9}'|cut -c1-3`
fi
current_hd_c=$current_hd"c"
current_hd_a=$current_hd"a"
current_hd_b=$current_hd"b"
current_hd_g=$current_hd"g"
echo "done"
# User input device name of the new disk
echo
echo "Please enter the device name of the new disk, e.g. \"rz2\" where 2 is"
echo -n "the scsi id of the new disk: "
read new_hd
new_hd_c=$new_hd"c"
new_hd_a=$new_hd"a"
new_hd_b=$new_hd"b"
new_hd_g=$new_hd"g"
echo
echo -n "Clearing disklabel on the new disk $new_hd ... "
disklabel -z $new_hd >/dev/null 2>&1
echo "done"
echo
echo "Dumpping filesystem from system disk $current_hd_c to new disk $new_hd_c"
echo -n "this may take more than half an hour depend on the size of the filesystem "
dd if=/dev/$current_hd_c of=/dev/$new_hd_c conv=noerror,sync bs=512k &
# waiting dots, a little decoration
id=$!
while ps ax | grep "^[[:space:]]*$id" > /dev/null
do
echo -n "."
sleep 5
done
#if [ $? != 0 ]; then
# echo "Dump error, exit"
# exit 2
#fi
echo
echo "Dump completed"
echo
echo "Checking file integrity of the new disk ..."
echo -n "Checking partition a ..."
fsck /dev/$new_hd_a
echo
echo -n "Checking partition g ..."
fsck /dev/$new_hd_g
echo
echo
echo -n "Changing fstab and swapdefault ... "
umount /mnt >/dev/null 2>&1
mount -t ufs /dev/$new_hd_a /mnt
if [ $? != 0 ]; then
echo "Mount error, exit"
exit 2
fi
if [ "$version" = "V4.0D" ]; then
cd /mnt/etc
#cat fstab
cp fstab fstab.sav
#cat fstab | sed -e 's/rz0a/rz2a/' -e 's/rz0g/rz2g/' -e 's/rz0b/rz2b/g' > temp
cat fstab | sed 's/rz0/'$new_hd'/g' > temp
mv temp fstab
cd /mnt/sbin
rm swapdefault
ln -s /dev/$new_hd_b swapdefault
fi
if [ "$version" = "v4.0G" ]; then
cd /mnt/etc
cp fstab fstab.sav
cat fstab | sed 's/rz0/'$new_hd'/g' > fstab
cd /mnt/etc/fdmns/root_domain
ln -fs /dev/$new_hd_a $new_hd_a
cd /mnt/etc/fdmns/usr_domain
ln -fs /dev/$new_hd_g $new_hd_g
cd /mnt/sbin
rm swapdefault
ln -s /dev/$new_hd_b swapdefault
fi
cd /
umount /mnt
echo "done"
echo
echo
echo "Now please issue the command \"shutdown -h now\" to halt the system and then"
echo "type \"b dka???\" under >>> console prompt to boot from the clonned disk,"
echo "where ??? can be determined by \"show dev\". Should the reboot be successful,"
echo "the old disk can be safely removed."
echo
我爱臭豆腐 回复于:2004-03-21 07:19:56 |
:em27: 好给你加为了精华。希望以后能够有更多的好帖子 |
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/