This is the second post/script in this series, the first script is Oracle RMAN Database Full Hot Backup Script
The following script will fully backup the database while it is closed (in the mount state). This backup will be a consistent backup that needs no archive logs to be recovered.
# **************************************************************************************
# $Header: abc_rman_full_cold_bkp.sh *
# **************************************************************************************
# * Author: Ahmed Abdel Fattah *
# **************************************************************************************
# * DESCRIPTION: Take rman full cold backup(incremental level 0 ) *
# * Backing up archive logs is just redundant *
# * 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 <<USAGEINFO
******************************************************************
** USAGE: abc_rman_full_cold_bkp.sh **
** where Is the SID of Database to be backed up. **
** **
** Prerequisits: **
** – Login as oracle user **
** – Ensure that the DB is open **
** – Configure FRA , if not already configured **
******************************************************************
USAGEINFO
exit 1
fi
# Set the Oracle Environment
# —————————
export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/dbhome_1
export ORACLE_SID=$1
export PATH=$ORACLE_HOME/bin:$PATH:.
oh=$ORACLE_HOME
dt=”_`date ‘+%Y%m%d’`”
sid=$1
lg=”/backup/$sid/log/rman_full_cold$dt.log”
#lg=”/home/oracle/$sid/log/rman_full_cold$dt.log”
echo Script $0 >> $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;
shutdown immediate;
startup mount;
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_cold_backup’ plus archivelog tag ‘weekly_cold_backup’;
release channel c1 ;
release channel c2 ;
release channel c3 ;
release channel c4 ;
}
sql ‘alter database open’;
exit
EOF
echo ========== Completed at `date` ========== >> $lg

Donate to support our blogging work
$1.00
Thanks
Ahmed
2 thoughts on “Oracle RMAN Database Full Cold Backup Script”