Databases Reference
In-Depth Information
SET HEAD OFF FEEDBACK OFF
SELECT COUNT(*) FROM
(SELECT (sysdate - MAX(end_time)) delta
FROM v\$rman_backup_job_details) a
WHERE a.delta > $2;
EOF)
#
if [ $crit_var -ne 0 ]; then
echo "rman backups not running on $1" | mailx -s "rman problem" dbasupport@gmail.com
else
echo "rman backups ran ok"
fi
#
exit 0
You'll have to adjust this code to work in your environment. The code uses a script named oraset to establish
the Oracle operating system variables, such as ORACLE_HOME, ORACLE_SID, and PATH. You'll have to replace the
invocation of that script with whatever method you use to instantiate these operating system variables. Also you'll
need to replace the e-mail address with one of your own.
Assuming the script is placed in a file named rman_chk.bsh, you can determine whether the backups have run
for the DWREP database within the past day by running the script as follows:
$ rman_chk.bsh DWREP 1
If no RMAN jobs have run at all within the past day, an e-mail will be sent indicating that there may be an issue.
You can automate the script in a Linux/Unix environment by placing an entry in cron . The following entry runs
the RMAN check job on a daily basis:
25 6 * * * /u01/oracle/bin/rman_chk.bsh DWREP 1>/u01/oracle/bin/log/rman_chk.log 2>&1
Many oracle data dictionary views contain a $ character as part of the view name. When referencing a V$ view
within a shell script, you must escape the $ character and tell the shell to not treat it as a shell variable. This is done with
a \ character.
Tip
How It Works
It's extremely important to have some automated method for detecting whether the RMAN backups are running
successfully. You can modify the shell script presented in the Solution section to meet the needs of your environment.
The script in the solution section is a very simple yet effective way of determining whether RMAN is running. The
script won't detect every issue, but it will let you know if RMAN hasn't run a successful job within the specified period.
Along those lines, here's another simple script that will let you know if there's a data file that hasn't been backed
up within the specified time period:
#!/bin/bash
#
if [ $# -ne 2 ]; then
echo "Usage: $0 SID threshold"
exit 1
fi
 
 
Search WWH ::




Custom Search