Re: [Veritas-bu] RMAN backup status
2009-01-11 05:38:52
Hi there,
We use an RMAN script for all of our Oracle database backups and it sends all
of its logs to a /var/adm/log/bkup_logs directory on the server where each
database produces a <database name>_<date>.out file. Each backup appends new
info into this log until the date changes at which point it starts a new log.
I've pasted our script below. It works very well for our DBA's when
troubleshooting backup issues. I can't take much credit for any of this
script. Most of it was from a canned script with all the important changes
having been made by previous DBA's and backup admins.
########################################################################################################################################################################################################
#!/bin/sh
# $Header: oracle_backup.sh $
#
#
# ---------------------------------------------------------------------------
# Insert Changes made here, along with the date:
# ---------------------------------------------------------------------------
#
# Copied from hot_database_backup.sh provided by Veritas: 03/08/05
#
# 08/19/05 - Updated for OEM - Modified rman command to nocatalog
# - added control file backup
# ---------------------------------------------------------------------------
# Determine the user which is executing this script.
# ---------------------------------------------------------------------------
CUSER=`id |cut -d"(" -f2 | cut -d ")" -f1`
ORATAB=/var/opt/oracle/rman_oratab
export ORATAB
x=0
for i in `cat $ORATAB | grep -v \* | grep -v \# | awk -F: '{print $1}'`
do
ORACLE_SID=""
export ORACLE_SID
ORACLE_HOME=""
export ORACLE_HOME
TNS_ADMIN=""
export TNS_ADMIN
ORACLE_SID=$i
export ORACLE_SID
ORACLE_HOME=`cat $ORATAB | grep -v \* | grep -v \# | grep $ORACLE_SID |
head -1 | awk -F: '{print $2}'`
export ORACLE_HOME
if [ -d $ORACLE_HOME/network/admin/$ORACLE_SID'_'`hostname` ];
then
TNS_ADMIN=$ORACLE_HOME/network/admin/$ORACLE_SID'_'`hostname`
else
TNS_ADMIN=$ORACLE_HOME/network/admin
fi
export TNS_ADMIN
ORACLE_USER=oracle
export ORACLE_USER
# ---------------------------------------------------------------------------
# Create the Logfile
# Note: output directory requires write permission.
# ---------------------------------------------------------------------------
LOG_DIR=/var/adm/log/bkup_logs
RMAN_LOG_FILE=$LOG_DIR/$ORACLE_SID'_'`date '+%m%d%y'`.out
echo $RMAN_LOG_FILE
# -----------------------------------------------------------------
# Initialize the log file.
# -----------------------------------------------------------------
echo >> $RMAN_LOG_FILE
chmod 666 $RMAN_LOG_FILE
# ---------------------------------------------------------------------------
# Log the start of this script.
# ---------------------------------------------------------------------------
echo "########################################################################"
>> $RMAN_LOG_FILE
echo "########################################################################"
>> $RMAN_LOG_FILE
echo "#### ####"
>> $RMAN_LOG_FILE
echo "#### BACKUP STARTED ####"
>> $RMAN_LOG_FILE
echo "#### ####"
>> $RMAN_LOG_FILE
echo "########################################################################"
>> $RMAN_LOG_FILE
echo "########################################################################"
>> $RMAN_LOG_FILE
echo $0 initiated backup of $ORACLE_SID >> $RMAN_LOG_FILE
echo ==== started on `date` ==== >> $RMAN_LOG_FILE
echo >> $RMAN_LOG_FILE
# ---------------------------------------------------------------------------
# Set the target connect string.
# Replace "sys/manager", below, with the target connect string.
# ---------------------------------------------------------------------------
TARGET_CONNECT_STR=/
# ---------------------------------------------------------------------------
# Set the Oracle Recovery Manager name.
# ---------------------------------------------------------------------------
RMAN=$ORACLE_HOME/bin/rman
# ---------------------------------------------------------------------------
# Print out the value of the variables set by this script.
# ---------------------------------------------------------------------------
echo >> $RMAN_LOG_FILE
echo "RMAN: $RMAN" >> $RMAN_LOG_FILE
echo "ORACLE_SID: $ORACLE_SID" >> $RMAN_LOG_FILE
echo "ORACLE_USER: $ORACLE_USER" >> $RMAN_LOG_FILE
echo "ORACLE_HOME: $ORACLE_HOME" >> $RMAN_LOG_FILE
echo "TNS_ADMIN: $TNS_ADMIN" >> $RMAN_LOG_FILE
# ---------------------------------------------------------------------------
# Print out the value of the variables set by bphdb.
# ---------------------------------------------------------------------------
echo >> $RMAN_LOG_FILE
echo "NB_ORA_FULL: $NB_ORA_FULL" >> $RMAN_LOG_FILE
echo "NB_ORA_INCR: $NB_ORA_INCR" >> $RMAN_LOG_FILE
echo "NB_ORA_CINC: $NB_ORA_CINC" >> $RMAN_LOG_FILE
echo "NB_ORA_SERV: $NB_ORA_SERV" >> $RMAN_LOG_FILE
echo "NB_ORA_POLICY: $NB_ORA_POLICY" >> $RMAN_LOG_FILE
echo "NB_ORA_PC_SCHED: $NB_ORA_PC_SCHED" >> $RMAN_LOG_FILE
# ---------------------------------------------------------------------------
# NOTE: This script assumes that the database is properly opened. If desired,
# this would be the place to verify that.
# ---------------------------------------------------------------------------
echo >> $RMAN_LOG_FILE
# ---------------------------------------------------------------------------
# If this script is executed from a NetBackup schedule, NetBackup
# sets an NB_ORA environment variable based on the schedule type.
# The NB_ORA variable is then used to dynamically set BACKUP_TYPE
# For example, when:
# schedule type is BACKUP_TYPE is
# ---------------- --------------
# Automatic Full INCREMENTAL LEVEL=0
# Automatic Differential Incremental INCREMENTAL LEVEL=1
# Automatic Cumulative Incremental INCREMENTAL LEVEL=1 CUMULATIVE
#
# For user initiated backups, BACKUP_TYPE defaults to incremental
# level 0 (full). To change the default for a user initiated
# backup to incremental or incremental cumulative, uncomment
# one of the following two lines.
# BACKUP_TYPE="INCREMENTAL LEVEL=1"
# BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"
#
# Note that we use incremental level 0 to specify full backups.
# That is because, although they are identical in content, only
# the incremental level 0 backup can have incremental backups of
# level > 0 applied to it.
# ---------------------------------------------------------------------------
if [ `ps -ef | grep $ORACLE_SID | grep -v grep | wc -l` -lt 2 ]
then
/usr/bin/rm $RMAN_LOG_FILE
else
if [ "$NB_ORA_INCR" = "1" -o "$NB_ORA_CINC" = "1" ]
then
echo "Archive backup requested" >>
$RMAN_LOG_FILE
#Archive log backup
CMD_STR="
ORACLE_HOME=$ORACLE_HOME
export ORACLE_HOME
ORACLE_SID=$ORACLE_SID
export ORACLE_SID
TNS_ADMIN=$TNS_ADMIN
export TNS_ADMIN
$RMAN target $TARGET_CONNECT_STR catalog
rman/rman@oem msglog $RMAN_LOG_FILE append << EOF
RUN {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch02 TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch03 TYPE 'SBT_TAPE';
send 'NB_ORA_POLICY=$NB_ORA_POLICY';
send 'NB_ORA_PC_SCHED=$NB_ORA_PC_SCHED';
# backup all archive logs
BACKUP
# filesperset 20
FORMAT 'b_%u_%p_%c'
ARCHIVELOG ALL;
}
EXIT
"
else
echo "Hot backup requested" >> $RMAN_LOG_FILE
#Hotbackup
CMD_STR="
ORACLE_HOME=$ORACLE_HOME
export ORACLE_HOME
ORACLE_SID=$ORACLE_SID
export ORACLE_SID
TNS_ADMIN=$TNS_ADMIN
export TNS_ADMIN
$RMAN target $TARGET_CONNECT_STR catalog
rman/rman@oem msglog $RMAN_LOG_FILE append << EOF
RUN {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch02 TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch03 TYPE 'SBT_TAPE';
send 'NB_ORA_POLICY=$NB_ORA_POLICY';
send 'NB_ORA_PC_SCHED=$NB_ORA_PC_SCHED';
BACKUP
INCREMENTAL LEVEL=0
SKIP INACCESSIBLE
# FILESPERSET 5
# recommended format
FORMAT 'bk_%s_%p_%t'
DATABASE;
# backup all archive logs
sql 'alter system archive log current';
BACKUP
filesperset 20
FORMAT 'al_%s_%p_%t'
ARCHIVELOG ALL DELETE INPUT;
BACKUP
format 'cntrl_%t_%s_p%p'
current controlfile;
}
CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT OBSOLETE;
EXIT
"
fi
# Initiate the command string
if [ "$CUSER" = "root" ]
then
su - $ORACLE_USER -c "$CMD_STR" >>
$RMAN_LOG_FILE
RSTAT=$?
else
/usr/bin/sh -c "$CMD_STR" >> $RMAN_LOG_FILE
RSTAT=$?
fi
#
---------------------------------------------------------------------------
# Log the completion of this script.
#
---------------------------------------------------------------------------
if [ "$RSTAT" = "0" ]
then
LOGMSG="ended successfully"
else
LOGMSG="ended in error"
fi
echo >> $RMAN_LOG_FILE
echo Script $0 >> $RMAN_LOG_FILE
echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILE
echo >> $RMAN_LOG_FILE
echo "########################################################################"
>> $RMAN_LOG_FILE
echo "########################################################################"
>> $RMAN_LOG_FILE
echo "#### ####"
>> $RMAN_LOG_FILE
echo "#### BACKUP ENDED ####"
>> $RMAN_LOG_FILE
echo "#### ####"
>> $RMAN_LOG_FILE
echo "########################################################################"
>> $RMAN_LOG_FILE
echo "########################################################################"
>> $RMAN_LOG_FILE
fi
x=x+1
if [ x = 10 ];
then
EXIT 0
fi
done
###########################################################################################################################################################################################################
Hope that this is helpful for you.
Mark Glazerman
Desk: 314-889-8282
Cell: 618-520-3401
please don't print this e-mail unless you really need to
-----Original Message-----
From: veritas-bu-bounces AT mailman.eng.auburn DOT edu
[mailto:veritas-bu-bounces AT mailman.eng.auburn DOT edu] On Behalf Of
nbujohnson
Sent: Saturday, January 10, 2009 7:23 AM
To: VERITAS-BU AT mailman.eng.auburn DOT edu
Subject: [Veritas-bu] RMAN backup status
Hi All,
I am using netbackup-rman template to backup our oracle databases & i am need
of a script which will give me status report of rman failures (includes client
name ,db name date/time & error output etc).
Please let me know if anyone using any script like this.
Thanks,
John
+----------------------------------------------------------------------
|This was sent by nbujohnson AT googlemail DOT com via Backup Central.
|Forward SPAM to abuse AT backupcentral DOT com.
+----------------------------------------------------------------------
_______________________________________________
Veritas-bu maillist - Veritas-bu AT mailman.eng.auburn DOT edu
http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu
_______________________________________________
Veritas-bu maillist - Veritas-bu AT mailman.eng.auburn DOT edu
http://mailman.eng.auburn.edu/mailman/listinfo/veritas-bu
|
|
|