Sample routine for backing up FRA (Flash Recovery Area) to TAPE

Prerequisite:

1. Agent for media library is installed & Media management layer is configured correctly
2. Backup policy is configured on tape library

#!/bin/sh
#
# —————————————————————————
# flash_backup.sh
# —————————————————————————
# This will backup FRA from disk to TAPE. This is oracle recommended approach for backups.
# Backup is already available on disk (FRA)
# —————————————————————————

# —————————————————————————
# Determine the user which is executing this script.
# —————————————————————————

RUNUSER=`id cut -d”(” -f2 cut -d “)” -f1`

# —————————————————————————
# output log
# —————————————————————————

RMAN_LOG=${0}.out

if [ -f “$RMAN_LOG” ]
then
rm -f “$RMAN_LOG”
fi

# —————————————————————–
# Initialize log
# —————————————————————–

echo >> $RMAN_LOG
chmod 666 $RMAN_LOG

# —————————————————————————
# Start of this script.
# —————————————————————————

echo Script $0 >> $RMAN_LOG
echo ==== started on `date` ==== >> $RMAN_LOG
echo >> $RMAN_LOG

ORACLE_HOME=/u01/app/oracle/product/10.2.0
export ORACLE_HOME

ORACLE_SID=TESTDB2
export ORACLE_SID

ORACLE_USER=oracle

TARGET_CONNECT_STR=/

RMAN=$ORACLE_HOME/bin/rman

echo >> $RMAN_LOG
echo “RMAN: $RMAN” >> $RMAN_LOG
echo “ORACLE_SID: $ORACLE_SID” >> $RMAN_LOG
echo “ORACLE_USER: $ORACLE_USER” >> $RMAN_LOG
echo “ORACLE_HOME: $ORACLE_HOME” >> $RMAN_LOG
echo >> $RMAN_LOG

RMAN_CMD=”
ORACLE_HOME=$ORACLE_HOME
export ORACLE_HOME
ORACLE_SID=$ORACLE_SID
export ORACLE_SID
$RMAN target=$TARGET_CONNECT_STR catalog=RMAN_CATALOG/PASSWORD log=$RMAN_LOG append << EOF
RUN
{
ALLOCATE CHANNEL ch00 TYPE ‘SBT_TAPE’;
ALLOCATE CHANNEL ch01 TYPE ‘SBT_TAPE’;
BACKUP RECOVERY AREA;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
}
EOF

# Initiate the command string

if [ “$RUNUSER” = “root” ]
then
su – $ORACLE_USER -c “$RMAN_CMD” >> $RMAN_LOG
ECODE=$?
else
/usr/bin/sh -c “$RMAN_CMD” >> $RMAN_LOG
ECODE=$?
fi

# —————————————————————————
# End of script
# —————————————————————————

if [ “$ECODE” = “0” ]
then
LOGMSG=”ended successfully”
else
LOGMSG=”ended in error”
fi

echo >> $RMAN_LOG
echo Script $0 >> $RMAN_LOG
echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG
echo >> $RMAN_LOG

exit $ECODE

—————————————————————————
BACKUP LOG
—————————————————————————

Script /usr/openv/netbackup/ext/db_ext/oracle/samples/rman/flash_backup.sh
==== started on Fri Jan 11 03:39:54 GMT 2008 ====

RMAN: /u01/app/oracle/product/10.2.0/bin/rman
ORACLE_SID: TESTDB2
ORACLE_USER: oracle
ORACLE_HOME: /u01/app/oracle/product/10.2.0

Sun Microsystems Inc. SunOS 5.10 Generic January 2005
RMAN> 2> 3> 4> 5> 6> 7> 8> RMAN> .3.0 – Production on Fri Jan 11 03:39:54 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: TESTDB (DBID=1631972037)
connected to recovery catalog database

RMAN> 2> 3> 4> 5> 6> 7> 8>
allocated channel: ch00
channel ch00: sid=103 instance=TESTDB2 devtype=SBT_TAPE
channel ch00: VERITAS NetBackup for Oracle – Release 5.1 (2005081403)

allocated channel: ch01
channel ch01: sid=101 instance=TESTDB2 devtype=SBT_TAPE
channel ch01: VERITAS NetBackup for Oracle – Release 5.1 (2005081403)

Starting backup at 11-JAN-08
specification does not match any datafile copy in the repository
skipping archive log file +FLASH/TESTDB/archivelog/2008_01_10/thread_1_seq_2325.434.643677175; already backed up 1 time(s)
skipping backupset key 6890; already backed up 1 time(s)
skipping backupset key 6891; already backed up 1 time(s)
skipping backupset key 6892; already backed up 1 time(s)
skipping backupset key 6894; already backed up 1 time(s)
skipping backupset key 6895; already backed up 1 time(s)
skipping backupset key 6896; already backed up 1 time(s)
skipping backupset key 6899; already backed up 1 time(s)
channel ch00: starting archive log backupset
channel ch00: specifying archive log(s) in backup set
input archive log thread=1 sequence=2326 recid=4557 stamp=643692350
channel ch00: starting piece 1 at 11-JAN-08
input backupset count=4548 stamp=643675832 creation_time=10-JAN-08
channel ch01: starting piece 1 at 11-JAN-08
channel ch01: backup piece +FLASH/TESTDB/backupset/2008_01_10/nnndf0_full_backup_testdb_0110081050_0.451.643675833
channel ch00: finished piece 1 at 11-JAN-08
piece handle=efj5rukm_1_1 tag=TAG20080111T034005 comment=API Version 2.0,MMS Version 5.0.0.0
channel ch00: backup set complete, elapsed time: 00:02:56
input backupset count=4552 stamp=643676971 creation_time=10-JAN-08
channel ch00: starting piece 1 at 11-JAN-08
channel ch00: backup piece +FLASH/TESTDB/autobackup/2008_01_10/s_643676971.501.643676975
piece handle=e4j5rdlo_1_2 comment=API Version 2.0,MMS Version 5.0.0.0
channel ch01: finished piece 1 at 11-JAN-08
channel ch01: backup set complete, elapsed time: 00:04:02
input backupset count=4556 stamp=643677022 creation_time=10-JAN-08
channel ch01: starting piece 1 at 11-JAN-08
channel ch01: backup piece +FLASH/TESTDB/backupset/2008_01_10/annnf0_full_backup_testdb_0110081050_0.510.643677027
piece handle=c-1631972037-20080110-01 comment=API Version 2.0,MMS Version 5.0.0.0
channel ch00: finished piece 1 at 11-JAN-08
channel ch00: backup set complete, elapsed time: 00:03:04
input backupset count=4554 stamp=643677022 creation_time=10-JAN-08
channel ch00: starting piece 1 at 11-JAN-08
channel ch00: backup piece +FLASH/TESTDB/backupset/2008_01_10/annnf0_full_backup_testdb_0110081050_0.431.643677025
piece handle=ecj5requ_1_2 comment=API Version 2.0,MMS Version 5.0.0.0
channel ch01: finished piece 1 at 11-JAN-08
channel ch01: backup set complete, elapsed time: 00:03:16
input backupset count=4555 stamp=643677022 creation_time=10-JAN-08
channel ch01: starting piece 1 at 11-JAN-08
channel ch01: backup piece +FLASH/TESTDB/backupset/2008_01_10/annnf0_full_backup_testdb_0110081050_0.371.643677025
piece handle=eaj5requ_1_2 comment=API Version 2.0,MMS Version 5.0.0.0
channel ch00: finished piece 1 at 11-JAN-08
channel ch00: backup set complete, elapsed time: 00:03:44
input backupset count=4553 stamp=643677022 creation_time=10-JAN-08
channel ch00: starting piece 1 at 11-JAN-08
channel ch00: backup piece +FLASH/TESTDB/backupset/2008_01_10/annnf0_full_backup_testdb_0110081050_0.393.643677025
channel ch01: finished piece 1 at 11-JAN-08
channel ch01: backup set complete, elapsed time: 00:03:10
Finished backup at 11-JAN-08

Starting Control File and SPFILE Autobackup at 11-JAN-08
piece handle=c-1631972037-20080111-00 comment=API Version 2.0,MMS Version 5.0.0.0
Finished Control File and SPFILE Autobackup at 11-JAN-08

released channel: ch00

released channel: ch01

RMAN>

Recovery Manager complete.

Script /usr/openv/netbackup/ext/db_ext/oracle/samples/rman/flash_backup.sh
==== ended successfully on Fri Jan 11 03:58:09 GMT 2008 ====

Advertisements
This entry was posted in Oracle Database Backup, Oracle Recovery Manager and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s