Tuesday, October 20, 2015

RMAN: Cold Backup Script

#!/bin/sh
# Set Oracle Environment for DB
#. ~/.bashrc
. ~/.bash_profile

echo
echo "`date` – Started `basename $0`"
echo

export NLS_DATE_FORMAT='DD-MON-YY HH24:MI:SS'
rman target / << EOF
spool log to rman_coldbackup.log;
set echo on
run
{
shutdown immediate;
startup mount;
allocate channel ch1 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';
allocate channel ch2 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';
allocate channel ch3 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';
allocate channel ch4 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';
allocate channel ch5 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';
allocate channel ch6 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';

BACKUP CURRENT CONTROLFILE format '/export/dbclone/DEV_RMAN_COLDBKP/ctrl_file_%d_%s_%p';
BACKUP AS COMPRESSED BACKUPSET DATABASE;

release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
release channel ch6;

alter database open;
}
EOF
if [ $? -eq 0 ]
then
echo "====================="
echo "RMAN Backup Completed"
echo "====================="
else
echo "=================="
echo "RMAN Backup Failed"
echo "=================="
exit 1
fi

echo
echo "`date` - Finished `basename $0`"
echo

No comments:

Post a Comment