#!/bin/ksh # ------------------------------------------------------------------------- # This is a shell script for making exports directly to tape with a label. # This label contains the db name and timestamp. # # This script also verifies the tape's protection. If the tape is # protected it will display an error message and ask for a new tape. # # Another function lists the tape's label and its contents (option show=y # of export). # # This script also writes a history log with dbname and timestamp. # # Sergio Klimberg # ------------------------------------------------------------------------- clear echo ' ORACLE TAPE EXPORTS ' echo ' ------------------- ' b=' ' while [ "$b" != "end" ] do echo echo "* Enter DB for backup or list / Type 'end' to finish" echo ' ' read b if [ "$b" = "end" ] then exit fi echo ' ' echo "* Mount the tape and hit Enter or type 'list' / Type 'end' to finish" echo ' ' echo ' - Warning , Verify tape is not protected for backup ' echo ' - If are you going to list the result will appear on screeen and into /tmp/list.txt' echo ' ' read a echo ' ' read a if [ "$a" = "end" ] then exit fi mt -t /dev/rmt/0m rew # if [ "$a" = "list" ] then echo echo "<= Export's Header =>" tar tf /dev/rmt/0mn echo " " echo "* Hit Enter for show the export's remainder / Type 'end' to finish" echo ' ' read c if [ "$c" = "end" ] then exit fi echo 'file=/dev/rmt/0m ' >list.imp echo 'log=/tmp/list.txt' >>list.imp echo 'show=y' >>list.imp echo 'volsize=4000M' >>list.imp echo 'full=y ' >>list.imp echo 'back/xxxxxx@'$b >>list.imp imp parfile=list.imp 2>&1 echo echo "Type 'end' to finish " read d exit fi HORA="`date '+%d-%m-%y %H:%M:%S'`" DESC_EXPORT="EXPORT $b $HORA" touch "$DESC_EXPORT" tar cvf /dev/rmt/0mn "$DESC_EXPORT" 2>/dev/null RTA=$? while [ $RTA != 0 ] do echo "Tape protected , Hit ENTER when it's ready / Type 'end' to finish" read RTA1 if [ "$RTA1" = "end" ] then exit fi tar cvf /dev/rmt/0mn "$DESC_EXPORT" 2>/dev/null RTA=$? done TIME_START="`date '+%d/%m/%y %H:%M:%S'`" echo 'back/xxxxxx@'$b >PARAMETERS.EXP echo 'file=/dev/rmt/0m ' >>PARAMETERS.EXP echo 'log=export.log' >>PARAMETERS.EXP echo 'volsize=4000M' >>PARAMETERS.EXP echo 'full=y ' >>PARAMETERS.EXP echo ' ' >>all_export.log echo 'EXPORT OF : '$b >>all_export.log echo 'START : ' $TIME_START >>all_export.log echo ' ' >>all_export.log exp parfile=PARAMETERS.EXP 2>&1 | tee -a all_export.log echo ' ' >>all_export.log TIME_END="`date '+%d/%m/%y %H:%M:%S'`" echo 'END : ' $TIME_END >>all_export.log echo "$TIME_START | $TIME_END | $b ">>export_resumen.log echo ' ' echo "$TIME_START | $TIME_END | $b ">>export_resumen.log echo ' ' echo Export $b end OK done