RMAN L1 Backup Automation
RMAN L1 Backup Automation
RMAN L1 Backup Automation
Sometimes, in addition to L0 Backup DBA also needs to take RMAN L1 backup due
to many reasons like rman refresh, recovery etc. and during that time DBA needs to
execute the L1 backup command but the biggest challenge comes for the DBA when
the database size is huge and also the changes made after the L0 backup also huge in
size which can takes many hours to complete and they can’t run that L1 backup in
foreground so to overcome this challenge we can use rman automation backup script
which takes database L1 backup in background.
NOTE A: Change database service name as per your environment highlighted in red.
NOTE B: You don’t need to set database environment and if you’ve already set then
it’s also fine, just pass the correct database name along with the script name as
defined above in “Format to run the script” section and the automation
automatically set the environment for the database.
NOTE C: If you’re using this automation against RAC database then comment the
line highlighted in green and uncomment the line highlighted in brown & bold.
NOTE D: If the database size is huge in several TB, then also use section size clause
in L0 backup command.
BODY OF SCRIPT
#!/bin/bash
#set -xv
#set -n
mkdir -p /tmp/DB_L1_BKP
BKP_LOG=/tmp/DB_L1_BKP
RMAN_LOG=$BKP_LOG/L1_BKP.log
DBNAME=$1
DBNAME=`ps -ef |grep -i ora_pmon_$1 | grep -v grep | awk '{print $8}' | cut -d "_"
-f3`
#DBNAME=`ps -ef |grep -i ora_pmon_$1 | grep -v grep | awk '{print $8}' | cut -d
"_" -f3 | sed 's/.$//'`
DB_STATUS=`ps -ef|grep -i ora_pmon_$1 | grep -v grep | wc -l`
if [ ${DB_STATUS} -eq 1 ]
then
export ORACLE_SID=`ps -ef | grep -i ora_pmon_$1 | grep -v grep | cut -d "_" -f 3`
proid=`ps -ef | grep -i ora_pmon_$1 | grep -v grep | awk '{print $2}'`
var=`ls -l /proc/$proid/cwd | cut -d ">" -f 2 | sed 's/^ //'`
export ORACLE_HOME=`echo "${var%/*}"`
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE=`ls -l /proc/$proid/cwd | cut -d ">" -f 2 | sed 's/^ //' | awk -
F "/product" '{print $1}'`
$ORACLE_HOME/bin/sqlplus -s "/ as sysdba" << EOF >>$BKP_LOG/db_info.log
set lines 300 colsep '|'
select name from v\$database;
show parameter db_unique_name;
exit;
EOF
else
echo "Database $1 Is Not Running"
exit 1;
fi
SAMPLE OUTPUT