Databases Reference
In-Depth Information
Table 9-1. ( continued )
Line Number
Explanation
After we exit the RMAN command line, we capture the return code, $? .
87
88
We merge the RMAN log with the script log file.
89
We remove the lock file created earlier to indicate that the script has completed its run and
a new script run may be started.
87
We check the status of the RMAN execution. 0 indicates successful execution.
91
If the script fails for any reason, the return code will not be 0. The exact return code is
immaterial; the cause of the error will be captured in the RMAN log file. The error is notified
to the DBA's pager. The log file is sent to the pager and the DBA's e-mail.
95
If the RMAN execution was successful, we copy the log file to one of the locations where the
backups are generated. The tape backup software will pick it up from that location.
99-100
The log file is also copied to the central log server.
101
The temporary log file is removed.
The beauty of the solution script is that it's useful for any type of RMAN run—full, incremental, merge, archivelog,
and so on; it also can be applied to any database on any server. All you have to do is change the values of the
parameters in the script to reflect the correct target.
Scheduling a Unix Shell File
Problem
You want to run a backup shell script using a Unix scheduler, such as cron .
Solution
The cron utility in Unix is a built-in scheduler that can kick off any shell script at a certain time. You can decide a
specific day to run a script, or you can repeatedly run a script based on weekday and time, such as every Monday at
8 a.m. You enable a shell script to be run from cron by placing a reference to it in the crontab file. The crontab file
is a text file with one line per execution. The lines have several fields indicating the execution times, with each field
separated by a space. Here is an example of a crontab file:
00 11 * * 0 /opt/oracle/tools/rman_full.disk.sh > /opt/oracle/tools/rman_full.disk.log 2>&1
00 11 * * 0 /opt/oracle/tools/rman_arc.disk.sh > /opt/oracle/tools/rman_arc.disk.log 2>&1
These two lines show the execution properties of two programs under the cron scheduler: rman_full.disk.sh and
rman_arc.disk.sh. The lines have several fields separated by spaces. These fields denote the execution times. Table 9-2
later in the chapter describes the fields. In general, the fields are shown as follows:
<minute> <hour> <date> <month> <weekday> <program>
The cron tool then runs the <program> at <hour>:<minute> on the <date> of the <month>. If <weekday> is
specified, the program is run on the weekday at that time. If any of these entries have an asterisk (*) in them, the
asterisk is ignored.
 
 
Search WWH ::




Custom Search