Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

Backup and Restore Oracle Databases using

Spectrum Protect for Oracle


Contents

1. Installation and configuration of SP for Oracle.......................................................................3


2. Performing backup using RMAN...............................................................................................5
2.1 RMAN Backup Script..........................................................................................................5
2.2 Retention of Backups.......................................................................................................12
2.3 Backup Schedule..............................................................................................................12
2.4 How to perform Backup....................................................................................................12
2.5 Performing Archive log backup.......................................................................................15
3. FAQS..........................................................................................................................................15
1. Installation and configuration of SP for Oracle

1) Move the TDP Oracle 8.x package to Target Server

2) Unzip the package

3) Install the Package using InstallP

3.1 installp -agYXd GSKit8.gskcrypt64.ppc.rte GSKit8.gskssl64.ppc.rte


tivoli.tsm.client.oracle.aix.64bit tivoli.tsm.client.oracle.tools.aix.64bit

4) Edit the dsm.sys /usr/tivoli/tsm/client/ba/bin64/dsm.sys and link the file

ln -s /usr/tivoli/tsm/client/api/bin64/dsm.sys /usr/tivoli/tsm/client/ba/bin64/dsm.sys

Add the nodename , TCPServeraddress according to DEV/UAT IP address

ServerName ORACLE

nodename INVDBDV_ORA

COMMMethod TCPip

TCPPort 11500

TCPServeraddress 10.20.66.48

domain ALL-LOCAL

schedlogname /home/oracle/TSM/dsmsched_Oracle.log

schedlogretention 7 D

errorlogname /home/oracle/TSM/dsmerror_Oracle.log

errorlogretention 7 D

deduplication yes

enablededupcache yes

dedupcachesize 2048

resourceutil 4

passwordaccess generate

passworddir /home/oracle/TSM

managedservices schedule
4) Create dsm.opt on /usr/tivoli/tsm/client/oracle/bin64

dsm.opt

Servername ORACLE

5) Create TDPO.opt on /usr/tivoli/tsm/client/oracle/bin64 pointing to dsm.opt

DSMI_ORC_CONFIG /usr/tivoli/tsm/client/oracle/bin64/dsm.opt

6) Create a symbolic Link to library file using ROOT USER

ln -s /usr/tivoli/tsm/client/oracle/bin64/libobk64.a (Oracle_Home)/lib/libobk.a

For Ex:

ln -s /usr/tivoli/tsm/client/oracle/bin64/libobk64.a
/u01/app/oracle/product/12.2.0.1/dbhome_1/lib/libobk.a

7) Create password file

dsmc set password passw0rd passw0rd type=tsm -servername=ORACLE

2. Performing backup using RMAN

2.1 RMAN Backup Script


#!/bin/ksh
TSTAMP=`date +%Y%m%d_%H%M`
export ORACLE_SID=$2
exec>/home/oracle/TSM/logs/${ORACLE_SID}.${1}.${TSTAMP}.log 2>&1
echo "## START at `date +%Y%m%d_%H%M%S`"
RC=0
JOB_START=`date +%s`
echo "\nStarting at `date +'%Y%m%d_%H%M%S'`\n"
DAILY ()
{
if [ ! -f /home/oracle/TSM/$ORACLE_SID ];then
touch /home/oracle/TSM/$ORACLE_SID
rman << EOF
connect target /
run
{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 31 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE DEFAULT DEVICE TYPE TO sbt;
CONFIGURE DEVICE TYPE sbt PARALLELISM 6;
CONFIGURE CHANNEL DEVICE TYPE sbt PARMS
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c1 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c2 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c3 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c4 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c5 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c6 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
backup as backupset incremental level 0 tag="FULL_DB_BKUP" format '%d_CLVL0_%T_%u_s%s_p
%p' filesperset 5 (database);
#backup as backupset archivelog all tag="ARCHIVE" format '%d_ARC_%T_%u_s%s_p%p' delete
input;
backup current controlfile tag="CONTROLFILE" format 'ctl_rm_%d_%s_%p';
sql 'alter system archive log current';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;

}
allocate channel for maintenance device type sbt;
DELETE NOPROMPT obsolete recovery window of 31 days device type sbt;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
EOF
echo "$0 finished RC=$RC \n"
rm /home/oracle/TSM/$ORACLE_SID
return $RC
else
echo " Incremental Backup Already in progress"
fi

exit $RC
}

WEEKLY ()

if [ ! -f /home/oracle/TSM/$ORACLE_SID ];then

touch /home/oracle/TSM/backup

rman << EOF

connect target /
run
{
#CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 31 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE DEFAULT DEVICE TYPE TO sbt;
CONFIGURE DEVICE TYPE sbt PARALLELISM 6;
CONFIGURE CHANNEL DEVICE TYPE sbt PARMS
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c1 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c2 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c3 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c4 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c5 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c6 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';

backup as backupset incremental level 0 tag="WEEKLY_FULL_DB_BKUP" format '%d_CLVL0_%T_


%u_s%s_p%p' filesperset 5 (database);
#backup as backupset archivelog all tag="ARCHIVE" format '%d_ARC_%T_%u_s%s_p%p' delete
input;
backup current controlfile tag="CONTROLFILE" format 'ctl_rm_%d_%s_%p';
sql 'alter system archive log current';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
}
allocate channel for maintenance device type sbt;
DELETE FORCE NOPROMPT BACKUPSET TAG 'WEEKLY_FULL_DB_BKUP' COMPLETED
BEFORE 'SYSDATE-93';
EOF
echo "$0 finished RC=$RC "
rm /home/oracle/TSM/$ORACLE_SID
return $RC
else
echo " Incremental Backup Already in progress"
fi
exit $RC
}
MONTHLY ()
{
if [ ! -f /home/oracle/TSM/$ORACLE_SID ];then
touch /home/oracle/TSM/$ORACLE_SID
rman << EOF
connect target /
run
{
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE DEFAULT DEVICE TYPE TO sbt;
CONFIGURE DEVICE TYPE sbt PARALLELISM 6;
CONFIGURE CHANNEL DEVICE TYPE sbt PARMS
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c1 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c2 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c3 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c4 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c5 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c6 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
backup as backupset incremental level 0 tag="MONTHLY_FULL_DB_BKUP" format '%d_CLVL0_
%T_%u_s%s_p%p' filesperset 5 (database);
#backup as backupset archivelog all tag="ARCHIVE" format '%d_ARC_%T_%u_s%s_p%p' delete
input;
backup current controlfile tag="CONTROLFILE" format 'ctl_rm_%d_%s_%p';
sql 'alter system archive log current';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
}
allocate channel for maintenance device type sbt;
DELETE FORCE NOPROMPT BACKUPSET TAG 'MONTHLY_FULL_DB_BKUP' COMPLETED
BEFORE 'SYSDATE-366';
EOF
echo "$0 finished RC=$RC "
rm /home/oracle/TSM/$ORACLE_SID
return $RC
else
echo " Incremental Backup Already in progress"
fi
echo "Archiving Backup log files"
dsmc archive "/home/oracle/TSM/logs/*.log" -deletefiles -su=yes -se=oracle
exit $RC
}
YEARLY ()
{
if [ ! -f /home/oracle/TSM/$ORACLE_SID ];then
touch /home/oracle/TSM/$ORACLE_SID
rman << EOF
connect target /
run
{
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE DEFAULT DEVICE TYPE TO sbt;
CONFIGURE DEVICE TYPE sbt PARALLELISM 6;
CONFIGURE CHANNEL DEVICE TYPE sbt PARMS
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c1 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c2 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c3 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c4 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c5 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c6 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
backup as backupset incremental level 0 tag="YEARLY_FULL_DB_BKUP" format '%d_CLVL0_%T_
%u_s%s_p%p' filesperset 5 (database);
backup as backupset archivelog all tag="ARCHIVE" format '%d_ARC_%T_%u_s%s_p%p' delete
input;
backup current controlfile tag="CONTROLFILE" format 'ctl_rm_%d_%s_%p';
sql 'alter system archive log current';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
release channel c6;
}
allocate channel for maintenance device type sbt;
DELETE FORCE NOPROMPT BACKUPSET TAG 'YEARLY_FULL_DB_BKUP' COMPLETED
BEFORE 'SYSDATE-1830';
EOF
echo "$0 finished RC=$RC "
rm /home/oracle/TSM/$ORACLE_SID
return $RC
else
echo " Incremental Backup Already in progress"
fi
exit $RC
}
ARCHIVE ()
{
if [ ! -f /home/oracle/TSM/"${2}.backup" ];then
touch /home/oracle/TSM/"${2}.backup"
rman target / << EOF
run
{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 31 DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE DEFAULT DEVICE TYPE TO sbt;
CONFIGURE CHANNEL DEVICE TYPE sbt PARMS
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c1 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c2 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel c3 type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
backup as backupset archivelog all tag="ARCHIVE" format '%d_ARC_%T_%u_s%s_p%p' delete
input;
backup current controlfile tag="CONTROLFILE" format 'ctl_rm_%d_%s_%p';
sql 'alter system archive log current';
release channel c1;
release channel c2;
release channel c3;
}
allocate channel for maintenance device type sbt parms
'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
EOF
RC=$?
echo "$0 finished RC=$RC "
rm /home/oracle/TSM/"${2}.backup"
return $RC
else
echo " Backup Already in progress"
fi
}
"$@"
JOB_END=`date +%s`
echo "Ending at `date +'%Y%m%d_%H%M%S'`"
echo "Completed in $((($JOB_END - $JOB_START)/60)) minutes"
echo "Normal Exit"
2.2 Retention of Backups
Daily backup Retention – 31 Days
Weekly Backup - 90 Days
Monthly Backup - 1 Year
Yearly Backup - 5 Years

Retention is controlled in RMAN script using following command ( For ex:)

DELETE FORCE NOPROMPT BACKUPSET TAG 'MONTHLY_FULL_DB_BKUP' COMPLETED


BEFORE 'SYSDATE-366';

2.3 Backup Schedule


Weekly backup is performed on Saturday of every week ,
Monthly backup is scheduled on last week Saturday
Yearly backup is scheduled on last Saturday of December

Backup is scheduled from Crontab on Oracle User Instance ID

2.4 How to perform Backup


Rman script is located at /home/Oracle/TSM/rman.ksh
It is invoked by 2 positional paramaters

1 Parameter is for backup Type – Daily , Weekly , Monthly or Yearly


2 Parameter is for Oracle Instance to perform backup

./rman.ksh Daily INVIEW51 &

Log file will be generated in /home/Oracle/TSM/logs

Sample Log file

[root@RHPP-INORAC01 logs]# ls -l
-rw-r--r--. 1 oracle oinstall 12006 Dec 27 15:43 INVIEW51.ARCHIVE.20191227_1540.log
-rw-r--r--. 1 oracle oinstall 11777 Dec 28 14:06 INVIEW51.ARCHIVE.20191228_1402.log
-rw-r--r--. 1 oracle oinstall 4471 Dec 28 15:52 INVIEW51.ARCHIVE.20191228_1551.log
-rw-r--r--. 1 oracle oinstall 63746 Dec 29 13:31 INVIEW51.DAILY.20191229_1258.log
-rw-r--r--. 1 oracle oinstall 62947 Dec 24 00:18 INVIEW51.WEEKLY.20191223_2354.log
-rw-r--r--. 1 oracle oinstall 64036 Dec 27 13:22 INVIEW51.WEEKLY.20191227_1257.log
-rw-r--r--. 1 oracle oinstall 2837 Dec 28 13:58 INVIEW51.YEARLY.20191228_1358.log

channel c1: finished piece 1 at 29-DEC-19


piece handle=INVIEW5_CLVL0_20191229_kmukl296_s7830_p1 tag=FULL_DB_BKUP
comment=API Version 2.0,MMS Version 8.1.0.0
channel c1: backup set complete, elapsed time: 00:00:58
channel c1: starting incremental level 0 datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00345 name=/oradata01/INVIEW5/WMS1_WH100_I01.dbf
input datafile file number=00356 name=/oradata01/INVIEW5/WMS1_WH104_D01.dbf
input datafile file number=00185 name=/oradata01/INVIEW5/WMS1_WH53_D01.dbf
input datafile file number=00374 name=/oradata01/INVIEW5/WMS1_WH110_I01.dbf
input datafile file number=00120 name=/oradata01/INVIEW5/WMS1_WH30_I01.dbf
channel c1: starting piece 1 at 29-DEC-19
channel c2: finished piece 1 at 29-DEC-19
piece handle=INVIEW5_CLVL0_20191229_knukl299_s7831_p1 tag=FULL_DB_BKUP comment=API
Version 2.0,MMS Version 8.1.0.0
channel c2: backup set complete, elapsed time: 00:00:59
channel c2: starting incremental level 0 datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00141 name=/oradata01/INVIEW5/WMS1_WH37_I01.dbf
input datafile file number=00368 name=/oradata01/INVIEW5/WMS1_WH108_D01.dbf
input datafile file number=00260 name=/oradata01/INVIEW5/WMS1_WH66_D01.dbf
input datafile file number=00261 name=/oradata01/INVIEW5/WMS1_WH66_I01.dbf
input datafile file number=00180 name=/oradata01/INVIEW5/WMS1_WH51_I01.dbf
channel c2: starting piece 1 at 29-DEC-19
channel c5: finished piece 1 at 29-DEC-19
piece handle=INVIEW5_CLVL0_20191229_koukl29b_s7832_p1 tag=FULL_DB_BKUP comment=API
Version 2.0,MMS Version 8.1.0.0
channel c5: backup set complete, elapsed time: 00:01:12
channel c5: starting incremental level 0 datafile backup set
channel c5: specifying datafile(s) in backup set
input datafile file number=00114 name=/oradata01/INVIEW5/WMS1_WH28_I01.dbf
input datafile file number=00226 name=/oradata01/INVIEW5/WMS1_WH72_I01.dbf
input datafile file number=00375 name=/oradata01/INVIEW5/WMS1_WH110_D01.dbf
input datafile file number=00253 name=/oradata01/INVIEW5/WMS1_WH77_I01.dbf
input datafile file number=00209 name=/oradata01/INVIEW5/WMS1_WOL05_D01.dbf
channel c5: starting piece 1 at 29-DEC-19
channel c4: finished piece 1 at 29-DEC-19
piece handle=INVIEW5_CLVL0_20191229_kpukl29q_s7833_p1 tag=FULL_DB_BKUP comment=API
Version 2.0,MMS Version 8.1.0.0
channel c4: backup set complete, elapsed time: 00:01:04
channel c6: finished piece 1 at 29-DEC-19
piece handle=INVIEW5_CLVL0_20191229_klukl296_s7829_p1 tag=FULL_DB_BKUP comment=API
Version 2.0,MMS Version 8.1.0.0
channel c6: backup set complete, elapsed time: 00:01:32
channel c2: finished piece 1 at 29-DEC-19
piece handle=INVIEW5_CLVL0_20191229_ksukl2b4_s7836_p1 tag=FULL_DB_BKUP comment=API
Version 2.0,MMS Version 8.1.0.0
channel c2: backup set complete, elapsed time: 00:00:50
channel c3: finished piece 1 at 29-DEC-19
piece handle=INVIEW5_CLVL0_20191229_kqukl2at_s7834_p1 tag=FULL_DB_BKUP comment=API
Version 2.0,MMS Version 8.1.0.0
channel c3: backup set complete, elapsed time: 00:00:57
channel c1: finished piece 1 at 29-DEC-19
piece handle=INVIEW5_CLVL0_20191229_krukl2b1_s7835_p1 tag=FULL_DB_BKUP comment=API
Version 2.0,MMS Version 8.1.0.0
channel c1: backup set complete, elapsed time: 00:01:03
channel c5: finished piece 1 at 29-DEC-19
piece handle=INVIEW5_CLVL0_20191229_ktukl2bj_s7837_p1 tag=FULL_DB_BKUP comment=API
Version 2.0,MMS Version 8.1.0.0
channel c5: backup set complete, elapsed time: 00:00:45
Finished backup at 29-DEC-19

Starting backup at 29-DEC-19


channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 29-DEC-19
channel c1: finished piece 1 at 29-DEC-19
piece handle=ctl_rm_INVIEW5_7838_1 tag=CONTROLFILE comment=API Version 2.0,MMS Version
8.1.0.0
channel c1: backup set complete, elapsed time: 00:00:07
Finished backup at 29-DEC-19

Starting Control File and SPFILE Autobackup at 29-DEC-19


piece handle=c-3427745383-20191229-00 comment=API Version 2.0,MMS Version 8.1.0.0
Finished Control File and SPFILE Autobackup at 29-DEC-19

sql statement: alter system archive log current

released channel: c1

released channel: c2

released channel: c3

released channel: c4

released channel: c5

released channel: c6

RMAN>
allocated channel: ORA_MAINT_SBT_TAPE_1
channel ORA_MAINT_SBT_TAPE_1: SID=1141 instance=INVIEW51 device type=SBT_TAPE
channel ORA_MAINT_SBT_TAPE_1: Data Protection for Oracle: version 8.1.0.0

RMAN>
no obsolete backups found

RMAN>
specification does not match any archived log in the repository

RMAN>

Recovery Manager complete.


./rman.ksh finished RC=0 \n ------ Indicates Backup completed successfully
Ending at 20191229_133148
Completed in 33 minutes
Normal Exit

2.5 Performing Archive log backup

./rman.ksh ARCHIVE INVIEW51 &


3. FAQS
1) Can Same Instance backup Triggered multiple times at same time

No ,Script File creates a lock file during backup and it prevents from running multiple backup at the
same time , following message will be displayed in log file

[root@RHPP-INORAC01 logs]# cat INVIEW51.YEARLY.20191228_1436.log


## START at 20191228_143645
\nStarting at 20191228_143645\n
Incremental Backup Already in progress

You might also like