Home > Oracle Database / Applications Tips > Oracle Database Administrator > Oracle backup and recovery scripts, part I: Cold backup under Unix
Oracle Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ORACLE DATABASE ADMINISTRATOR

Oracle backup and recovery scripts, part I: Cold backup under Unix


Rajendra Gutta
06.18.2003
Rating: -4.38- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Cold backups
Is a cold backup needed in addition to daily hot backups?
Cold backup on Unix server
What files need to be backed up under 9i for a cold backup?
Back up an Oracle database on a Linux platform
Moving datafiles from production to development by cold backup and renaming
Cold backup using RMAN
Step-by-step backup procedures
Try this simple cold backup script
Oracle backup and recovery scripts, part III: Backup and recovery under Windows NT

Oracle Database Administrator
Understanding SQL string functions
What is the difference between a database engineer, architect and administrator?
Import on one table from dump file
Error during RMAN backup
Can I drop a column in SYS schema?
STATSPACK tool: transaction vs. execution measurement
Should I port from Microsoft Access?
How can I find statistics on total memory usage and database connections?
Installing multiple Oracle homes
Modifying SYS password in a RAC environment

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


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 parameters—SID 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 database—what 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


Rate this Tip
To rate tips, you must be a member of SearchOracle.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Oracle Development Solutions - SQL, J2EE, XML, SOA
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts