中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 操作系统 > Tru64Unix
自动进行system disk clone 的 shell script (原创)
作者:未知 时间:2005-09-13 15:56 出处:ChinaUnix.net 责编:chinaitpower
              摘要:自动进行system disk clone 的 shell script (原创)

看到大家讨论好多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: 好给你加为了精华。希望以后能够有更多的好帖子

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有