Databases Reference
In-Depth Information
Solution
The most common platforms for Oracle databases are Unix and its variants, such as Linux, Solaris, HPUX, and so on.
The presence of a shell programming language is extremely handy when using these variants. In this recipe, you will
learn how to develop a complete shell script to call any RMAN script. Here are some expectations for the script:
cron .
It should be able to be run from some automated utility, such as
It should send an e-mail to a set of addresses after successful completion.
It should send an e-mail to another set of addresses after a failure.
It should back up to multiple mount points. In this example, we have assumed nine
mount points.
It should produce a log file whose name follows this format:
<ORACLE_SID>_<BACKUP_TYPE>_<BACKUP_MEDIA>_<TIMESTAMP>.log
The log file should show the time stamp in mm/dd/yy hh24:mi:ss format, not the default
dd-MON-yy format.
This log file should be copied over to a central server where all the DBA-related logs are kept.
In addition, the log file should be copied to one of the backup mount points as well.
The script should be generic enough to be called for any database. In other words, the script
should not hard-code components that will be different from database to database, such as
Oracle Home, SID, and so on.
The script should have a built-in locking mechanism; in other words, if the script is running
and is being called again, it shouldn't start.
With these requirements in mind, you can develop a script similar to the one that follows, which enables you
to back up any database automatically and on a recurring basis by using cron or some other job-scheduling utility.
(Our listing has line numbers to aid explanation; the actual script does not have those line numbers.) The script has
a configurable section in which you can replace the variable values to suit your environment.
1. # Beginning of Script
2. # Start of Configurable Section
3. export ORACLE_HOME=/opt/oracle/12.1/db_1
4. export ORACLE_SID=PRODB1
5. export TOOLHOME=/opt/oracle/tools
6. export BACKUP_MEDIA=DISK
7. export BACKUP_TYPE=FULL_DB_BKUP
8. export MAXPIECESIZE=16G
9. # End of Configurable Section
10. # Start of site specific parameters
11. export BACKUP_MOUNTPOINT=/oraback
12. export DBAEMAIL="dbas@proligence.com"
13. export DBAPAGER="dba.ops@proligence.com"
14. export LOG_SERVER=prolin2
15. export LOG_USER=oracle
16. export LOG_DIR=/dbalogs
17. export CATALOG_CONN=${ORACLE_SID}/${ORACLE_SID}@catalog
18. # End of site specific parameters
 
Search WWH ::




Custom Search