?? dumdum
字號:
#!/bin/csh -f # # dumdum: script to do incremental dumps #onintr quitumask 7# filesystems to be dumped on level 0 and 1set LOLEV = "root usr net"# filesystems to be dumped at every levelset ALWAYS = "usr net"# dump program to use set DUMP = "/etc/dump"# restore program to useset RESTORE = "/etc/restore"# density of the tapeset DEN = "1600"# device to dump toset DUMPDEV = "/dev/mt0"#directory where all dump information is storedset DUMPDIR = "/usr/local/adm/dumpdir"cd ${DUMPDIR}#set up temporary file namesset FLAGDIR = "${DUMPDIR}/flagdir"if (!(-d $FLAGDIR )) mkdir $FLAGDIR set FLAGFILE = "${FLAGDIR}/dumpit"set FNAME = "tmp"set TEMPFILE = "${FLAGDIR}/${FNAME}$$"# get the sequence information from the WHICHDUMP fileset which = `cat ${DUMPDIR}/WHICHDUMP`set DATEFILE = "${DUMPDIR}/DUMPDATES"@ lessone = ${#which} - 1set nonomatchstart:#if the last dump did not finish, restart itset junk = (`ls ${FLAGDIR}`)set isnotdone = (${junk})if (${#isnotdone} >= 1) then echo "THIS IS THE CONTINUATION OF AN ABORTED DUMP" echo "Continuing with a level ${which[${which[${#which}]}]} dump." echo " " echo -n "Is this correct? " set junk = $< while ((${junk} != "yes") && (${junk} != "no") && \ (${junk} != "y") && (${junk} != "n")) echo -n "Please answer yes or no: " set junk = $< end if ((${junk} == "n") || (${junk} == "no")) then rm -f ${FLAGDIR}/* goto start endif set restart goto getlevelelse# increment the position counter (last element of array) @ which[$#which]++# if the position counter points to its own position in the array, recycle# back to the beginning of the array if (${which[${#which}]} == ${#which}) set which[${#which}] = 1recover: echo "" echo -n "My records" if (${?limit}) echo -n " now" echo -n " indicate that this should be a " echo " level ${which[${which[${#which}]}]} dump." echo -n "Is this correct? " set junk = $< while ((${junk} != "yes") && (${junk} != "no") && \ (${junk} != "y") && (${junk} != "n")) echo -n "Please answer yes or no: " set junk = $< end if ((${junk} == "yes") || (${junk} == "y")) then echo $which > ${DUMPDIR}/WHICHDUMP# set the level - lolevel contains the number without sublevel informationgetlevel: set level = ${which[${which[${#which}]}]} set lolevel = `echo $level | tr -d "a-z"` else## list the dump sequence and corresponding numbers# echo "" @ limit = $#which / 5 set counter = 1 while ($counter <= $limit) set temp = $counter; set i = 1 while ($i <= 5) echo -n "${temp}==$which[$temp]" if ($temp == $which[$#which]) then echo -n "*" endif echo -n " " @ temp += 9; @ i++ end echo "" @ counter++; end echo "* marks the dumps I thought we were supposed to do." echo "" echo -n "What is the number of the correct dump? "# get the correct dump number set junk = $< while ((${junk} < "1") || (${junk} >= "${#which}")) echo "Please choose a number between 1 and ${lessone}\!" echo -n "What is the number of the correct dump? " set junk = $< end set which[${#which}] = ${junk} goto recover endifendifecho ""if ((${lolevel} == "0") || (${lolevel} == "1")) then set fs = "${LOLEV}"else set fs = "${ALWAYS}"endifecho "Doing these file systems: $fs"echo " "# cycle for each filesystem that needs to be doneforeach filesystem ( ${fs} ) if (!(-e ${FLAGFILE}.${filesystem})) then unset restart#look up raw device name in /etc/fstab if ($filesystem == "root") then set DEV = `awk -F: '$2 ~ /\/$/ { print $1}'\ /etc/fstab` else set DEV = `awk -F: '$2 ~ /'${filesystem}'$/\ { print $1}' /etc/fstab` endif#do the dump echo -n "Type 'yes' when the /${filesystem} tape is online: " set junk=$< while ((${junk} != "yes") && (${junk} != "y")) echo -n "Type 'yes' when the /$filesystem tape is online:" set junk=$< end echo "Doing the dump...." ${DUMP} ${lolevel}udf ${DEN} ${DUMPDEV} ${DEV} |& tee $TEMPFILE touch ${FLAGFILE}.${filesystem} else echo "Apparently the ${filesystem} dump has been done." endif# do the dumptoc if (!(-e ${FLAGFILE}.r${filesystem})) then echo -n "Doing the dumptoc..." ${RESTORE} tf ${DUMPDEV} > ${DUMPDIR}/lev${level}.${filesystem} touch ${FLAGFILE}.r${filesystem} echo "Done" if (-z ${DUMPDIR}/lev${level}.${filesystem}) then echo "PANIC\!" echo "${DUMPDIR}/lev${level}.${filesystem} is empty\!" endif echo -n "Level ${level} /${filesystem} " >> ${DATEFILE} echo -n `date` >> ${DATEFILE} echo " by ${USER}" >> ${DATEFILE} else echo "And the dumptoc for ${filesystem} has been done also." endifendrm -f ${FLAGFILE}.* goto cleanquit:echo ""echo "The dump has been killed.... I hope you know what you are doing\!"echo ""clean:rm -f ${FLAGDIR}/${FNAME}*cd
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -