Oracle RMAN Database Full Hot Backup Script

I was asked by one of my customers to develop some rman backup/restore scripts.

These scripts are a modified versions from some old scripts developed by me + some enhancement from other similar scripts .

Following is the first script in the series, it to fully backup the database while it is open.
— {Please fully test these scripts before using them in your specific environment} —

# ***********************************************************************
# $Header: abc_rman_full_hot_bkp.sh *
#************************************************************************
# * Author: Ahmed Abdel Fattah *
#************************************************************************
# * DESCRIPTION: Take rman full hot backup(incremental level 0 ) *
# * PLATFORM: Linux/Solaris/HP-UX/AIX *
#***********************************************************************

#!/bin/bash

# Check the login user to be “oracle”
# ————————————
usr=`id |cut -d”(” -f2 | cut -d “)” -f1`

if [ $usr != “oracle” ]
then
echo “You should login as oracle user”
exit 1
fi

# Check that ORACLE_HOME was set
# ——————————
#oh=$ORACLE_HOME
#if [ -z $oh ]
#then
# echo “You should set the oracle environment”
# exit 1
#fi

# Check that the user passed one parameter
# —————————————-

if [ $# -lt 1 ] ; then #not given enough parameters to script
cat <> $lg
echo >> $lg
echo ========== started on `date` ========== >> $lg
echo “ORACLE_SID: $sid” >> $lg
echo “ORACLE_USER: $usr” >> $lg
echo “ORACLE_HOME: $oh” >> $lg
echo “RMAN Log File: $lg” >> $lg
echo ============================================================ >> $lg

rman msglog $lg append << EOF

connect target / set echo on;

configure controlfile autobackup on;

run

{

sql "alter session set nls_date_format=''dd-mm-yyyy hh24:mi:ss''";

allocate channel c1 device type disk ;

allocate channel c2 device type disk ;

allocate channel c3 device type disk ;

allocate channel c4 device type disk ;
backup as compressed backupset incremental level 0 database tag 'weekly_hot_backup' plus archivelog tag 'weekly_hot_backup';

release channel c1 ;

release channel c2 ;

release channel c3 ;

release channel c4 ;

}

exit

EOF

echo ========== Completed at `date` ========== >> $lg

Donate to support our blogging work

$1.00

Thanks
Ahmed

4 thoughts on “Oracle RMAN Database Full Hot Backup Script

  1. Sir I have to write a simple script that execute the RMAN command “list copy of archivelog until ‘SYSDATE-7’ ” and store the output to a log file(suppose the log file location is in /u01/rman)

    Sir I tried a lot and ask many of my friends no one can give me the solution.

    Like

Leave a reply to Anirudh Kumar Cancel reply