Friday

Monitoring your RMAN backup scripts

There is an easy way to monitor your RMAN backup scripts in a unix environment. I've seen quite a few DBA's log the rman output to a file and then grep it for errors. Ex.


rman target / CMDFILE /home/oracle/scripts/rman.sql LOG $logfile
errors=`cat $logfile|grep -i error|wc -l`
if test $errors -gt 0
then
mailx -s "BACKUP FAILED" email1@myserver.com, email2@myserver.com <<\!
`cat $logfile`
!
fi

Another method would be to examine the return code from the rman client. Rman returns a value of 0 to the shell if the backup was successful. Otherwise it returns a nonzero value and from what I have seen this is always 1. (Have you seen any other values?)

So another way of writing the above script would be


rman target / CMDFILE /home/oracle/scripts/rman.sql LOG $logfile
status=$?

if [ $status -gt 0 ] ; then
mailx -s "BACKUP FAILED: TESTDB" email1@myserver.com <<\!
`cat $logfile`
\!
else
mailx -s "SuccessfulBackup: TESTDB" email1@myserver.com <<\!
`cat $logfile`
\!
fi

NOTE: Ignore the backlashes before the exclamation points above. I'm not sure how to format it properly within blogger. I'll see if I can fix it later.

As you can see above, after rman executes I set a status variable. $? is automatically set to the return code from the rman client. After that I check the value and there was an error I send an email saying the backup failed and put the contents of the log file into the body of the message. If the backup was successful, I still send a copy of the logfile.

The reason I do this is because each day I will expect to see either a successful or failed email. I've had issues in the past with cron not executing scheduled jobs (for numerous reasons). So if I don't receive an email I'll verify the backup manually.

6 comments:

Anonymous said...

Another quite different approach which I find very good is a user defined metric for the database in Enterprise Manager. This executes sql periodically to query v$rman_status and alert when there are failures.

Noons said...

A problem I've seen with some Linux and Unix ports is the cron daemon suddenly dies, with the result that crontab jobs, such as rman backups, don't start.

I've used nagios successfully to keep an eye on crond and make sure I know if it dies.

Anonymous said...

can you share your query for v$rman_status? I'm trying to setup email notification when a RMAN job fails. I checked with Oracle and they only offer this functionality in 11g dbconsole. I am currently using 10.2.0.3 and have RMAN setup through dbconsole using the controlfile, not a catalog. Thanks for your help

Dave said...

Hey, I just check the return code from RMAN. That will tell you if it was successful or not. Another commenter uses v$rman_status but I haven't looked into that personally.

ramesh rp said...

Hi

Form server configuration file's in placed two location's why
Fnd_top/resource
OA_HTML/bin

Sridevi Koduru said...

Regards
Sridevi Koduru (Senior Oracle Apps Trainer Oracleappstechnical.com)
LinkedIn profile - https://in.linkedin.com/in/sridevi-koduru-9b876a8b
Please Contact for One to One Online Training on Oracle Apps Technical, Financials, SCM, Oracle Manufacturing, OAF, ADF, SQL, PL/SQL, D2K at sridevikoduru@oracleappstechnical.com | +91 - 9581017828.