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.

8 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

Unknown 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.

Unknown said...

Hi

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

rmouniak said...

It 's an amazing and awesome blog
Oracle SOA Online Training Bangalore

Repairtech Solutions said...

This is the perfect site for anyone who wishes to find out about this topic. You realize a whole lot its almost hard to argue with you (not that I really would want to…HaHa). You certainly put a fresh spin on a topic which has been written about for years. Wonderful stuff, just excellent! onsite mobile repair bangalore Aw, this was a very nice post. Finding the time and actual effort to create a very good article… but what can I say… I put things off a whole lot and don't seem to get nearly anything done. asus display replacement I’m impressed, I must say. Rarely do I come across a blog that’s both educative and interesting, and without a doubt, you have hit the nail on the head. The problem is something which too few folks are speaking intelligently about. I am very happy I came across this in my search for something relating to this. huawei display repair bangalore

Repairtech Solutions said...

Nice post. I learn something totally new and challenging on websites I stumbleupon on a daily basis. It will always be helpful to read through content from other writers and practice something from other sites. vivo charging port replacement I blog often and I genuinely thank you for your information. This article has truly peaked my interest. I am going to book mark your website and keep checking for new information about once a week. I opted in for your RSS feed too. lg service center Bangalore Pretty! This was a really wonderful article. Thank you for supplying this info. motorola display repair bangalore