藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年6月26日 11:18


請點評!備份Solaris8系統的腳本

#!/bin/sh
#
# pragma ident   "@(#)Dump_single.sh    2005.09"
#
# This script can dump solaris 8 system to tape
#
# OS Version : Solaris 8 02/2004
#
# Hardware Supproted :Sun Platform
#
# User : root user
#
# Usage: #sh Dump_single.sh
#
# log file: /var/sadm/install/logs/dump_system_to_tape_log.xxxxxxx
#
###########################################################
echo "This script will dump solaris 8 system to tape."
echo "Please prepare the tape machine and insert an empty tape."
echo ""

MONTH=`/usr/bin/date +%m`
DAY=`/usr/bin/date +%d`
HOUR=`/usr/bin/date +%H`
MIN=`/usr/bin/date +%M`
LOG=/var/sadm/install/logs/dump_system_to_tape_log."$MONTH""$DAY""$HOUR""$MIN"

if [ $LANG -eq zh ]
then
    LANG=C
    export LANG
fi

echo "Dumping will be start now.\nStarting time:`date '+%y%m%d.%H:%M:%S'`" | tee $LOG

TMP_PATH=/tmp

SYSINFOPATH=/export/home/n2ksysinfo/`uname -i`
echo "Creating n2ksysinfo directory $SYSINFOPATH..." | tee -a $LOG
if [ -d /export/home/n2ksysinfo ]
then
    if [ -d "$SYSINFOPATH" ]
    then
        echo
    else
        mkdir "$SYSINFOPATH"
    fi
else
    if [ -d /export/home ]
    then
        echo
    else
        if [ -d /export ]
        then
            echo
        else
            mkdir /export
        fi
        mkdir /export/home
    fi
    mkdir /export/home/n2ksysinfo
    mkdir "$SYSINFOPATH"
fi

cd "$SYSINFOPATH"

echo "Backuping vfstab and system files..." | tee -a $LOG
cp /etc/vfstab ./vfstab.origin
cp /etc/system ./system.origin
cp /etc/path_to_inst ./path_to_inst.origin
df -k | grep 'dev/dsk' | grep -v cdrom | awk '{print $1}' > partitioninfo
df -k | grep 'dev/dsk' | grep -v cdrom | grep '/$' | awk '{print $1}' > rootpartitioninfo
cat partitioninfo | awk '{print substr($1,1,15)}' | sort -u > diskinfo

while read DISKS
do
    DISK=`echo $DISKS | awk -F"/" '{print $4}'`
    if [ -f "$DISK""s2".vtoc ]
    then
        rm "$DISK""s2".vtoc
    fi

    echo "Backuping partition map of disk $DISK..." | tee -a $LOG
    prtvtoc /dev/rdsk/"$DISK""s2" > ./"$DISK""s2".vtoc
done < "$SYSINFOPATH"/diskinfo

mt rewind

echo "Dumping script files to tape..." | tee -a $LOG
cd /export/home
/usr/sbin/ufsdump 0ucf /dev/rmt/0n n2ksysinfo

cd /

while read LINE
do
    echo "Dumping partition $LINE to tape..." | tee -a $LOG
    /usr/sbin/ufsdump 0ucf /dev/rmt/0n $LINE
done < "$SYSINFOPATH"/partitioninfo

echo "Rewind and offline tape..." | tee -a $LOG
mt rewind
mt offline

echo "Dumping is over.\nEnding time:`date '+%y%m%d.%H:%M:%S'`" | tee -a $LOG

看不太懂,有幾個命令不知道,sun一般一個40G的磁帶,一個ufsdump命令就差不多了吧?  沒深入瞭解過

是一個循環,按照分區進行備份

-->
是一個循環,按照分區進行備份。



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com