This is the first of a series of excerpts from "Oracle DBA automation scripts" by Rajendra Gutta. Click for part two on hot backup under Unix and part three on backup and recovery under Windows NT. You can purchase the book here.
The backup and recovery scripts discussed here have been tested under Sun
Solaris 2.x, HP-UX 11.x and AIX 4.x. The use of a particular command is
discussed if there is a difference between these operating systems. They might
also work in higher versions of the same operating system. These scripts are
written based on the common ground among these three Unix flavors. However, I
advise that you test the scripts under your environment for both backup and
recovery before using it as a regular backup script. This testing not only gives
you confidence in the script, it also gives you an understanding of how to use
the script in case a recovery is needed and gives you peace of mind when a
crisis hits.
Backup Scripts for HP-UX, Sun Solaris, and AIX
The backup scripts provided here work for HP-UX, Sun Solaris, and AIX with
one slight modification. That is, the scripts use v$parameter and
v$controlfile to get the user dump destination and control file
information. Because in Unix the dollar sign ($) is a special
character, you have to precede it with a forward slash (\) that tells
Unix to treat it as a regular character. However, this is different in each
flavor of Unix. AIX and HP-UX need one forward slash, and the Sun OS needs two
forward slashes to make the dollar sign a regular character.
Sun OS 5.x needs two \\
AIX 4.x needs one \
HP-UX 11.x needs one \
These scripts are presented in modular approach. Each script consists of a
number of small functions and a main section. Each function is designed to meet
a specific objective so that they are easy to understand and modify. These small
functions
To continue reading for free, register below or login
To read more you must become a member of SearchOracle.com
');
// -->

are reusable and can be used in the design of your own scripts. If you
want to change a script to fit to your unique needs, you can do so easily in the
function where you want the change without affecting the whole script.
After the backup is complete, it is necessary to check the backup status by
reviewing log and error files generated by the scripts.
Cold Backup
Cold backup program (see Listing 3.1) performs the cold backup of the database
under the Unix environment. The script takes two input parametersSID
and OWNER. SID is the instance to be backed up, and OWNER
is the Unix account under which Oracle is running. Figure
3.3 describes the functionality of the cold backup program. Each box represents
a corresponding function in the program:
[IMAGE]
Listing 3.1 coldbackup_ux
Cold Backup Script under Unix Checklist
Restore File
A cold backup program creates a restore file that contains the commands to
restore the database. This functionality is added based on the fact that a lot
of DBAs perform backups but, when it comes to recovery, they will not have any
procedures to make the recovery faster. With the restore file, it is easier to
restore files to the original location because it has all the commands ready to
restore the backup. Otherwise, you need to know the structure of the
databasewhat files are located where. A sample restore file is shown in
Listing 3.2.
Listing 3.2 Sample Restore File
Cold Backup Troubleshooting and Status Check
The important thing here is that the backup log file defined by
BACKUPLOGFILE contains detailed information about each step of the
backup process. This is a very good place to start investigating why the backup
failed or for related errors. This file will also have the start and end time of
the backup.
A single line about the success or failure of a backup is appended to
SID.log file every time a backup is performed. This file is located
under the directory defined by the LOGDIR variable. This file also has
the backup completion time. A separate file is created for each instance. This
single file maintains the history of performed backups and their status and
timing information. The messages for a cold backup are
'COLDBACKUP_FAIL' if a cold backup failed and
'Coldbackup Completed successfully' if a backup completes
successfully.
Apart from the BACKUPLOGFILE and SID.log files, it is
always good to capture the out-of-the-ordinary errors displayed onscreen if you
are running the backup unattended. You can capture these errors by running the
command shown next. The same thing can be done for hot backups. This command
captures onscreen errors to the coldbackup.log file.
The following is an excerpt from the SID.log file:
BACKUPLOGFILE
Listing 3.3 Sample BACKUPLOGFILE
Reader Feedback
Todd B. writes: I was looking at this tip and one thing that came to mind is it neglects
those who use a network backup system. I have created some scripts that test
for the presence of the backup daemon. Once the backup daemon is not there,
then I restart the database. This enables me to only have as much downtime
as necessary to get a complete cold backup. I also have a second script that
will check for the presence of the first. This is my "drop dead" script,
meaning that at a certain time, regardless if the backups have finished or
not, I need to have the database up. This script will kill the first script
waiting on the backup daemon, start the database, then e-mail the
administrators letting them know that we did not get a good backup.
For More Information