1. It will identified trace file
2. Edit trace file to make neat and clean script to create control file
3. Copy to identify folder.
How to execute
==============
50 16 * * * /home/oracle/scripts/backup_controlfile.ksh db_name
Output of script
=================
[oracle@dev ~]$ /home/oracle/scripts/backup_controlfile.ksh db_name
GETTING CONTROLFILE TRACE
Copied Trace file to /home/oracle/scripts/dev10g_fri_bk_control.sql
cp /oracle/admin/dev10g/udump/dev10g_ora_25079.trc /home/oracle/scripts/dev10g_fri.trc
Manipulating trace file
New backup Control file: /home/oracle/scripts/dev10g_fri_bk_control.sql
#=============Start of Script=============================
#/home/oracle/scripts/backup_controlfile.kshif [ $# -ne 1 ]then echo Usage Error. Please provide DBNames echo Usage: Ex. ./backup_controlfile.ksh dbname exitfi
export ORACLE_SID=$1BACKUP_FOLDER=/home/oracle/scripts/BACKUP_FILENAME_tmp=${ORACLE_SID}_`/bin/date +%a /usr/bin/tr A-Z a-z`.trcBACKUP_FILENAME=${ORACLE_SID}_`/bin/date +%a /usr/bin/tr A-Z a-z`_bk_control.sql#!/bin/kshecho ""echo ""echo "GETTING CONTROLFILE TRACE"echo ""(sqlplus /nolog<
#echo cp `cat $BACKUP_FOLDER/temptracefile` $BACKUP_FOLDER$BACKUP_FILENAME_tmpcp `cat $BACKUP_FOLDER/temptracefile` $BACKUP_FOLDER$BACKUP_FILENAME_tmpif [[ $? = 0 ]]thenecho ""echo ""echo "Copied Trace file to $BACKUP_FOLDER$BACKUP_FILENAME"echo " cp `cat $BACKUP_FOLDER/temptracefile` $BACKUP_FOLDER$BACKUP_FILENAME_tmp "echo ""echo ""elseecho "FAILED TO GET TRACE FILE"fi
echo "Manipulating trace file"echo ""echo "STARTUP NOMOUNT">$BACKUP_FOLDER$BACKUP_FILENAMEecho ""echo ""cat $BACKUP_FOLDER$BACKUP_FILENAME_tmpsed -e'/^#/d' -e'1,/STARTUP/d' -e'/STARTUP/,//d' -e'/CFILESETSNAPSHOTNAME/d' >> $BACKUP_FOLDER$BACKUP_FILENAMEecho " New backup Control file:" $BACKUP_FOLDER$BACKUP_FILENAME
#===================== end of script==================================
No comments:
Post a Comment