#!/bin/ksh
. ~/.profile
##
## script name : rman_config.ksh
## Author : Ramakrishna Nemani
##
## Purpose :
## This script takes database sid as a command line argument and configures
## persistent rman settings
##
## Other Features :
## This script creates a log file on the datbase server where this script is hosted.
##
## It also creates and uses a lockfile to make sure no other rman process is running for
## the database sid that was supplied through the command line. Should this script fail
## for any reason, it does not remove the lockfile so that no rman process can run for this
## database until the error is fixed and the lock file is removed manually.
##
##
## Note :
## You need to login as a unix user id that belongs to dba group and run this script.
## For device type sbt , the setting that I have here is for our TSM setup. Your setting may differ.
## I have tested this script on only Oracle 10g on an IBM AIX platform. Use it at your own risk.
##
## This is an example or sample script
##
##
## Make sure ORACLE_SID is passed as an argument
##
if (( $# < 1 ))
then
echo
echo Error Missing Arguement, Please supply Oracle Sid
echo
echo Usage: $0 ORACLE_SID
echo
exit
fi
export ORACLE_SID=$1
LOG_DIR="."
##
## Make sure no other rman process is running for this ORACLE_SID
##
LOCKFILE="${LOG_DIR}/$ORACLE_SID.lock"
while [ 1 ]
do
if [ -e $LOCKFILE ]
then
##
## Some rman process is running. Check again after 3 minutes
##
sleep 80
else
##
## No rman process is running. Create the lock file
##
echo Do not remove this file. This is a lock file for $ORACLE_SID > $LOCKFILE
break
fi
done
CURR_DATE=`date +"%Y%m%d_%H%M%S"`
##
## using two seperate files instead of one
## The LOGFILE will have log from just the latest run
## The ARCFILE will have cumulative log
##
## LOGFILE="${LOG_DIR}/rman_config_$CURR_DATE.$ORACLE_SID.log"
LOGFILE="${LOG_DIR}/rman_config.$ORACLE_SID.log"
ARCFILE="${LOG_DIR}/rman_config.$ORACLE_SID.arc"
##
## Run rman config commands
##
rman <<EOF > $LOGFILE
connect target / ;
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP
FORMAT FOR DEVICE TYPE DISK TO 'controlfile_%F';
CONFIGURE DEFAULT DEVICE TYPE TO DISK ;
CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET ;
CONFIGURE DEVICE TYPE sbt PARALLELISM 4 BACKUP TYPE TO BACKUPSET ;
CONFIGURE CHANNEL DEVICE TYPE sbt
PARMS 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)'
FORMAT '%u_%p_%c' ;
EOF
cat $LOGFILE >> $ARCFILE
##
## Remove lock file to allow other rman processs for this ORACLE_SID to run, if any
##
rm $LOCKFILE
## ---------------------------------------------------------------------------------
## End of rman_config.ksh
## ---------------------------------------------------------------------------------
TrackBack
TrackBack URL for this entry:
http://www.somberi.com/nrk-mt/mt-tb.fcgi/38
