开发学院操作系统Windows Vista NTBackup结合Solaris shell script执行自动备份 阅读

NTBackup结合Solaris shell script执行自动备份

 2009-02-07 17:44:07 来源:WEB开发网   
核心提示: 4,Solaris服务器,设定好相应的Shellscript,设定相应的Crontab项,NTBackup结合Solaris shell script执行自动备份(2),Crontab020**1-5/icil/server_common_lib/etc/NTBackup_unixxxxn

4,Solaris服务器,设定好相应的Shellscript,设定相应的Crontab项。

Crontab


020**1-5/icil/server_common_lib/etc/NTBackup_unixxxxnt01
07**2-6/icil/server_common_lib/etc/chk_w2kbkup_logxxxnt01backupadminWho1VBAicilillusion@icil.net

NTBackup_unix

#!/bin/sh
###############################################
#RSHW2KservertorunntbackupfromSolaris
#IllusionChen
###############################################
W2K_SRVR=$1
Today=`date+%w`
#ShowUsage
if[$#-lt1];then
    echo"Usage:`basename$0`<W2K_SRVR>;"
    echo"Comment:Accordingtothescript,W2KServerwillrunNTBackupscr
iptat23:10"
    exit
fi
#MainProgram
#if[${Today}-eq0-o${Today}-eq6];then
#   exit
#   else
if[${Today}-eq5];then
    rsh${W2K_SRVR}'AT23:10/interactiveD:icillibfullbackup.bat'
    else
    rsh${W2K_SRVR}'AT23:10/interactiveD:icillibdailybackup.bat'
fi
#fi

chk_w2kbkup_log

#IllusionChen


#!/bin/sh
#./.profile>;/dev/null
################################################################
#
# ScriptforCheckingWindows2000Backuplog-Unixside
#  Origin:Julian,Feb05,2001
#  Author:IllusionChen
#  Oct20th,2003
#  RunonSolaris8
#
################################################################
#  PleasecheckREADMEforreference
################################################################
W2K_SRVR=$1
BACKUP_OP=$2
PASSWD=$3
DOMAIN=$4
LOC_CONTACT=$5
MAILLIST=icil_sup@icil.net,${LOC_CONTACT}
NT_DRIVER=C$
#NT_LOG_PATH=
LOG_PATH=/icil/log/ntbackup
log=
if["${DOMAIN}x"="x"];then
    DOMAIN=`grep"workgroup"/usr/local/samba/lib/smb.conf|grep-v';'|g
rep-v'#'|awk'{print$NF}'`
fi
#Functions
#Logsin/icil/log/ntbackupforyourreference
chk_process()
{
date>;${LOG_PATH}/process_list
rsh${W2K_SRVR}'D:icilbintlist.exe'>;>;${LOG_PATH}/process_list
ifgrep"AccessDenied"${LOG_PATH}/process_list>;/dev/null;then
    (echo"Server:${W2K_SRVR}"
    echo"ConfigurationError"
    echo"RSH:AccessDeniedFrom`hostname`"
    echo"RSH:FailedtocheckNTBackupprocess"
    )>;>;${LOG_PATH}/chk_log_result
    cat${LOG_PATH}/chk_log_result|/usr/ucb/mail-s"NTBackup:Configurati
onError"${MAILLIST}
fi
ifgrep"notrecognized"${LOG_PATH}/process_list>;/dev/null;then
    (echo"Server:${W2K_SRVR}"
    echo"RSH:Commandnotrecognized"
    echo"RSH:FailedtocheckNTBackupprocess"
    )>;>;${LOG_PATH}/chk_log_result
    cat${LOG_PATH}/chk_log_result|/usr/ucb/mail-s"NTBackup:Configurati
onError"${MAILLIST}
fi
ifgrep"NTBACKUP.EXE"${LOG_PATH}/process_list>;/dev/null;then
    (echo"Server:${W2K_SRVR}"
    echo"Error:NTBackupprocessisstillrunning"
    echo"PleasecontactICILsupport"
    )>;>;${LOG_PATH}/chk_log_result
    cat${LOG_PATH}/chk_log_result|/usr/ucb/mail-s"NTBackup:Processis
stillrunning"${MAILLIST}
fi
}
get_log()
#Mayporttheoutputaboutsmbclientto${LOG_PATH}get_log_result.
{
cat<<-END|/usr/local/samba/bin/smbclient''${W2K_SRVR}''${NT_DRIVER}''${P
ASSWD}-U${BACKUP_OP}-W${DOMAIN}-E
    prompt
    cd"DocumentsandSettings"
    cd${BACKUP_OP}
    cd"LocalSettings"
    cd"ApplicationData"
    cd"Microsoft"
    cd"WindowsNT"
    cd"NTBackup"
    cd"data"
    mgetbackup*.log
    rmbackup*.log
    quit
    END
}
################################################
# SeveralFunctionsForFunction"chk_log"
# Start
################################################
no_log()
{
date>;${LOG_PATH}/chk_log_result
echo"">;>;${LOG_PATH}/chk_log_result
ifgrep"failed"${LOG_PATH}/get_log_result>;/dev/null;then
    cat${LOG_PATH}/get_log_result|/usr/ucb/mail-s"NTBackup:Failedtog
etNTBackuplogfrom${W2K_SRVR}"${MAILLIST}
    exit1
    else
    ifgrep"ERRDOS"${LOG_PATH}/get_log_result>;/dev/null;then
        cat${LOG_PATH}/get_log_result|/usr/ucb/mail-s"NTBackup:Fai
ledtogetNTBackuplogfrom${W2K_SRVR}"${MAILLIST}
        exit1
    else
    echo"NobackuplogwasfoundfromNTserver,pleasecontactICILsuppor
t.n">;>;${LOG_PATH}/chk_log_result
    cat${LOG_PATH}/chk_log_result|/usr/ucb/mail-s"NTBackup:Jobfailed
in${W2K_SRVR}on`date'+%b%e%y'`"${MAILLIST}
    fi
fi
}
small_log()
{
date>;${LOG_PATH}/chk_log_result
echo"">;>;${LOG_PATH}/chk_log_result
ifgrep"operationwasnotperformed"./tmp_log>;/dev/null;then
    ifgrep"aninvalidRemovableStoragebackupdestinationwasspecified"
${log}>;/dev/null;then
        (echo"Server:${W2K_SRVR}"
        echo""
        echo"NTBackup:ConfigurationError"
        echo"Pleasecheckwhetherthebackupdestinationisspecified
n"
        echo"---------------------------------------------------------"
        )>;>;${LOG_PATH}/chk_log_result
        cat./tmp_log>;>;${LOG_PATH}/chk_log_result
        cat${LOG_PATH}/chk_log_result|/usr/ucb/mail-s"NTBackup:Con
figurationError"${MAILLIST}
        else
        ifgrep"nounusedmediawasavailable"./tmp_log>;/dev/null;the
n
            (echo"Server:${W2K_SRVR}"
            echo""
            echo"Pleaseinsertoverwritablemediaintothedrive."
            echo"Overwritablemediaincludesscratch,blank,andre
cyclablemedia."
            echo"PleasenotethatdependingonthecurrentMediaOv
erwriteProtectionsetting,importedandallocatedmediamaybeoverwritableas
well."
            echo""
            echo"Ifmediawasinserted,pleasechecktheRemovable
StorageLibraryn"
            echo"--------------------------------------------------
-------"
            )>;>;${LOG_PATH}/chk_log_result
            cat./tmp_log>;>;${LOG_PATH}/chk_log_result
            cat${LOG_PATH}/chk_log_result|/usr/ucb/mail-s"NTBac
kup:Mediainsert"${MAILLIST}
        else
            cat./tmp_log>;>;${LOG_PATH}/chk_log_result
            echo"PleasecontactICILsupporter">;>;${LOG_PATH}/chk_
log_result
            cat${LOG_PATH}/chk_log_result|/usr/ucb/mail-s"NTBac
kup:NoOperationin${W2K_SRVR}on`date'+%b%e%y'`"${MAILLIST}
        fi
    fi
else
    cat./tmp_log>;>;${LOG_PATH}/chk_log_result
    echo"Thereareseveralerrorsduringbackup,PleasecontactICILsupport
">;>;${LOG_PATH}/chk_log_result
    cat${LOG_PATH}/chk_log_result|/usr/ucb/mail-s"NTBackup:Jobfailed
in${W2K_SRVR}on`date'+%h%d%Y'`"${MAILLIST}
fi
}
normal_log()
{
date>;${LOG_PATH}/chk_log_result
echo"">;>;${LOG_PATH}/chk_log_result
cat./tmp_log>;>;${LOG_PATH}/chk_log_result
if[`grep-i"error"${LOG_PATH}/chk_log_result|wc-l`-eq0];then
    cat${LOG_PATH}/chk_log_result|/usr/ucb/mail-s"NTBackup:Jobsucceed
edin${W2K_SRVR}on`date'+%h%d%Y'`"${MAILLIST}
    else
    echo""
    echo"Thereareseveralerrorsduringbackup,PleasecontactICILsupport
">;>;${LOG_PATH}/chk_log_result
    cat${LOG_PATH}/chk_log_result|/usr/ucb/mail-s"NTBackup:Jobfailed
in${W2K_SRVR}on`date'+%h%d%Y'`"${MAILLIST}
fi
}
###########
# End
###########
#Chk_log
chk_log()
{
if[!-fbackup*.log];then
    no_log
    exit1
    else
    chmod666./backup*.log
    logs=`/usr/bin/ls./backup*.log`
    forlogin${logs};do
        SIZE=`wc${log}|awk'{print$3}'`
        cat${log}|/usr/ucb/tr-c'[a-z][A-Z][0-9][SPACE]'>;./tmp_log
        if[${SIZE}-eq0];then
            no_log
        fi
        if[${SIZE}-gt0-a${SIZE}-le500];then
            small_log
        fi
        if[${SIZE}-gt500];then
            normal_log
        fi
    done
fi
}
#TapeAlert
clean_tape()
{
if[`date'+%w'`-eq5];then
    (date
    echo"Server:${W2K_SRVR}"
    echo"-------------------------------------------"
    echo"NTBackup:TapeDriveNeedCleaning"
    echo""
    echo"PleasecleanthetapedriveofyourW2KServerbyacleaningtape
beforeyouinsertthetoday'sbackuptape"
    )|/usr/ucb/mail-s"NTBackup:TapeDriveNeedCleaning"${LOC_CONTACT}
fi
}
insert_tape()
{
(date
echo"Server:${W2K_SRVR}"
echo"-------------------------------------------"
echo"NTBackup:MediaInsertRequired"
echo""
echo"Thisjustisakindlynotification."
echo"Pleaseremembertoinsertthetapeforbackuptoday."
)|/usr/ucb/mail-s"NTBackup:MediaInsertRequired"${LOC_CONTACT}
}
########################
# MainProgram
########################
#ShowUsage
if[$#-lt3];then
    echo"Usage:`basename$0`<W2K_SRVR>;<BACKUP_OP>;<PASSWD>;[DOMAIN][LOC
_CONTACT]"
    exit2
fi
#checkLOG_PATH
if[!-d${LOG_PATH}];then
    mkdir${LOG_PATH}
fi
touch${LOG_PATH}
chk_process
date>;${LOG_PATH}/get_log_result
echo"GetingtheNTBackuplogFromWin2kServer:${W2K_SRVR}n">;>;${LOG_PATH}/
get_log_result
get_log>;>;${LOG_PATH}/get_log_result
chk_log
mvbackup*.log${LOG_PATH}/
find${LOG_PATH}-namebackup*.log-mtime+14-exec'rm'{};
clean_tape
insert_tape

原文链接:http://bbs.chinaunix.net/viewthread.php?tid=238085

上一页  1 2 

Tags:NTBackup 结合 Solaris

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接