Oracle8i Backup and Recovery Guide
Release 8.1.5

A67773-01

Library

Product

Contents

Index

Prev Next

3
Developing a Backup and Recovery Strategy

This chapter offers guidelines and considerations for developing an effective backup and recovery strategy. It includes the following topics:

Choosing Backup Types

When developing your backup strategy, you need to know which types of backups you can perform. In each type of physical backup you either back up a file or group of files. This section defines and describes:

Logical Backups, also known as exports, are described in detail in Oracle8i Utilities.

Whole Database Backups

A whole database backup should include backups of the control file along with all database files that belong to a database. Whole database backups are the most common type of backup.

Whole database backups do not require you to operate the database in a specific archiving mode. Before performing whole database backups, however, be aware of the implications of backing up in ARCHIVELOG and NOARCHIVELOG modes (see "Choosing Between NOARCHIVELOG and ARCHIVELOG Mode").

Whole database backups can be consistent or inconsistent. This section contains the following topics:

See Also: For detailed procedures for backing up a database using RMAN commands, see Chapter 8, "Making Backups and Copies with Recovery Manager".

For detailed procedures for backing up a database using O/S commands, see Chapter 13, "Performing Operating System Backups".

Consistent Backups

A consistent backup of a whole database is a backup in which all read-write datafiles and control files have been checkpointed with respect to the same SCN. In addition, all the online, read-write datafiles are not "fuzzy," i.e., do not contain changes beyond the SCN in the header. Oracle determines whether a restore backup is consistent by checking all the datafile headers against the datafile header information contained in the control file.

The control files and datafiles are made consistent during a database checkpoint. The only tablespaces in a consistent backup that are allowed to have older SCNs are read-only and offline normal tablespaces, which are still consistent with the other datafiles in the backup because no changes have been made to these tablespaces and so no recovery is required. If the offline datafile's checkpoint SCN matches the offline-SCN in the control file, then Oracle know the datafile needs no redo.

The important point is that you can open the database after restoring a consistent whole database backup without applying redo logs because the data is already consistent: no action is required to make the data in the restored datafiles correct. Consequently, you can restore a year-old consistent backup of your database without performing media recovery and without Oracle performing instance recovery.


WARNING:

Only use a backup control file created during a consistent whole database backup if you are restoring the whole database backup and do not intend to perform recovery. If you intend to perform recovery and have a current control file, do not restore an older control file--unless performing point-in-time recovery to a time when the database structure was different from the current structure.  


The only way to make a consistent whole database backup is to shut down the database cleanly and make the backup while the database is closed. If a database is not shut down cleanly, e.g., an instance fails or you issue a SHUTDOWN ABORT statement, the database's datafiles are always inconsistent--unless you opened the database in read-only mode. Instance recovery will be required at open time.

A consistent whole database backup is the only valid backup option for databases running in NOARCHIVELOG mode, because otherwise redo will need to be applied to create consistency--and in NOARCHIVELOG mode Oracle overwrites redo records without archiving them first.

To make a consistent database backup current or to take it to a non-current point in time, perform media recovery. If you use a current control file for recovery, Oracle starts media recovery beginning at the lowest checkpoint SCN in the datafile headers; if you use a backup control file, Oracle starts media recovery using the lowest of the following: the control file SCN and the lowest SCN in the datafile headers.

To perform media recovery either apply archived redo logs or, if you are using Recovery Manager, apply incremental backups and/or archived logs. All redo data is located in the archived and online redo logs.

Inconsistent Backups

An inconsistent backup of a whole database is a backup in which all read-write datafiles and control files have not been checkpointed with respect to the same SCN. For example, one datafile header may contain an SCN of 100 while others contain an SCN of 95. Oracle will not open the database until these SCNs are made consistent, i.e., until all changes recorded in the online redo logs have been made to the datafiles.

If your database must be up and running 24 hours a day, 7 days a week, you have no choice but to perform inconsistent backups of a whole database. For example, a backup of an offline tablespace in an open database is inconsistent with other tablespaces because portions of the database are being modified and written to disk while the backup of the tablespace is progressing. The datafile headers for the online and offline datafiles may contain inconsistent SCNs. You must run your database in ARCHIVELOG mode to make open backups.

If you run the database in ARCHIVELOG mode, you can construct a whole database backup using backups of datafiles taken at different times. For example, if your database contains seven tablespaces, and you back up the control file as well as a different tablespace each night, in a week you will back up all tablespaces in the database as well as the control file. You can consider this backup as a whole database backup.

Inconsistent Closed Backups

You have the option of making inconsistent closed backups if a database is backed up after a system crash or SHUTDOWN ABORT. This type of backup is valid if the database is running in ARCHIVELOG mode, because both online and archived redo logs are available to make the backup consistent.


Note:

Oracle recommends that you do not make inconsistent, closed database backups in NOARCHIVELOG mode.  


If you run your database in NOARCHIVELOG mode, only back it up when you have closed it cleanly using the IMMEDIATE or NORMAL options. Inconsistent whole database backups of databases running in NOARCHIVELOG mode are usable only if the redo logs containing the changes made prior to the backup are available when you restore it--an unlikely occurrence.

The reason that NOARCHIVELOG inconsistent backups are not recommended is that the datafile headers of the backed up files contain different SCNs (a normal shutdown will guarantee the consistency of these SCNs), and because the database is in NOARCHIVELOG mode, no archived redo logs are available to apply the lost changes. For this reason, RMAN does not allow you to back up a database that has been running in NOARCHIVELOG mode and shut down abnormally because the backup is not usable for recovery.

The moral is: if you run your database in NOARCHIVELOG mode, always aim to have a backup that is usable without performing any recovery. This aim is defeated if you need to apply redo from logs to recover a backup. If you need redo data to make a database consistent, operate in ARCHIVELOG mode.

Figure 3-1 illustrates the various options available to you when perform whole database backups:

Figure 3-1 Whole Database Backup Options


Archiving Unarchived Redo Log Files

After open or inconsistent closed backups, always guarantee that you will have the redo necessary to recover the backup by archiving the unarchived redo logs. When the database is open, issue the following SQL statement to force Oracle to switch out of the current log and archive it as well as all other unarchived logs:

SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
 

When the database is mounted, open, or closed, issue the following SQL statement to force Oracle to archive all non-current redo logs:

SQL> ALTER SYSTEM ARCHIVE LOG ALL;

When the database is mounted, open, or closed, issue the following SQL statement to archive a specified log group, where integer is the number of the group:

SQL> ALTER SYSTEM ARCHIVE LOG GROUP integer;

Afterwards, back up all archived redo logs produced since the backup began. This operation ensures that you can use the backup and also allows you to delete the original archived logs from disk. If you do not have all archived redo logs produced during the backup, you cannot recover the backup because you do not have all the redo records necessary to make it consistent.

Backing Up the Control File

Unless you are making a consistent whole database backup, make a binary backup up your control file using the ALTER DATABASE command with the BACKUP CONTROLFILE option, specifying the backup destination in quotes. For example, enter:

SQL> ALTER DATABASE BACKUP CONTROLFILE TO '/oracle/copy/cf.f';

You can also back up the control file to a trace file. Use the script in the trace file, which is located in the location specified by the USER_DUMP_DEST parameter, to re-create the control file should it become necessary. Use the following syntax:

SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE;

Note that trace backups have one major disadvantage: they have no record of any previous backups made with the old control file.

See Also: For more information about backing up the control file using SQL statements, see "Performing Control File Backups".

Tablespace Backups

A tablespace backup is a backup of the datafiles that constitute the tablespace. The reason is that a tablespace is a logical grouping, whereas a datafile is a physical file--and only physical files can be physically backed up. For example, if tablespace TBS_2 contains datafiles 2, 3, and 4, then a backup of tablespace TBS_2 backs up those three datafiles.

Tablespace backups, whether online or offline, are only valid if the database is operating in ARCHIVELOG mode. The reason is that redo will be required to make the restored tablespace consistent with the other tablespaces in the database.

The only time a tablespace backup is valid for a database running in NOARCHIVELOG mode is when the tablespace is currently read-only or offline-normal. These cases are exceptions because no redo is required to recover them. For example, take the scenario depicted in Figure 3-2:

  1. You take tablespace TBS_2 offline normal at some time during day t.

  2. You make a backup of TBS_2 at day t + 5.

  3. You restore tablespace TBS_2 at day t + 10 using the backup made at day t + 5.

  4. You make tablespace TBS_2 read-write at day t + 15.

Figure 3-2 Tablespace Backups in NOARCHIVELOG Mode


Because there were necessarily no changes to the offline tablespace between t + 5 and t + 10, Oracle does not require media recovery. If you make the tablespace read-write at t + 15 and then subsequently attempt to restore the t + 5 backup, however, Oracle requires media recovery for the changes after t + 15. Consequently, you will only be able to open the database if all necessary redo is located in the online redo logs.

Datafile Backups

A datafile backup is a backup of a single datafile. Datafile backups, which are not as common as tablespace backups, are valid in ARCHIVELOG databases.

The only time a datafile backup is valid for a database in NOARCHIVELOG mode is if every datafile in a tablespace is backed up. You cannot restore the database unless all datafiles are backed up. The datafiles must be read-only or offline-normal.

Control File Backups

A control file backup is a copy of a database's control file. If the database is mounted, you can issue the following SQL statement, where controlfile_location is the name for the backup:

ALTER DATABASE BACKUP CONTROLFILE TO 'controlfile_location';

You can also back up to a trace file: the trace file contains a script for re-creating the control file. The statement is as follows:

ALTER DATABASE BACKUP CONTROLFILE TO TRACE;

You can also use the RMAN backup current controlfile command.

See Also: To learn how to make control file backups using SQL*Plus, see "Backing Up the Control File After Structural Changes". To learn how to make control file backups using RMAN, see "Backing Up Control Files".

Choosing Backup Methods

You can make physical backups using Recovery Manager or O/S commands and logical backups using a utility such as Export:

Table 3-1 Requirements for Different Backup Methods
Backup Method  Type  Version Available  Requirements 

Recovery Manager (RMAN)  

Physical  

Oracle version 8.0 and higher  

Media manager (if backing up to tape)  

O/S  

Physical  

All versions  

O/S backup utility (for example, UNIX dd)  

Export  

Logical  

All versions  

N/A  

Enterprise Backup Utility (EBU)  

Physical  

Oracle7 only  

Media manager  

Recovery Manager

The Recovery Manager (RMAN) utility manages Oracle backup and recovery operations. RMAN uses information about the database stored in the control file to automatically locate, back up, restore, and recover database files--including datafiles, control files, and archived redo logs. For example, RMAN can:

See Also: For a conceptual overview of Recovery Manager, see "Overview of Recovery Manager".

Recovery Manager Metadata

Recovery Manager obtains necessary information for its backup and recovery operations from either the control file or from an optional repository called a recovery catalog. The recovery catalog, which is maintained by RMAN, is a warehouse of information obtained from the control files of its target databases. RMAN refers to the data in the recovery catalog when directing server processes during restore and recover operations.

See Also: For a conceptual overview of the Recovery Manager metadata, see "Recovery Manager Metadata". To learn how to manage the RMAN metadata, see Chapter 6, "Managing Recovery Manager Metadata".

Media Management

To utilize tape storage for your Oracle database backups, RMAN requires a media manager. A media manager is a third-party software utility that loads, labels, and unloads sequential media such as tape drives for the purpose of backing up and recovering data.

The Oracle Backup Solutions Program (BSP) allows third-party vendors to easily integrate their products with the Recovery Manager; you can access online information about BSP via the following URL:

http://www.oracle.com/st/products/features/backup.html

Although media management software offers you the additional flexibility of backing up to both disk and tertiary storage, a media manager is not required if you only intend to back up to disk.

See Also: For a conceptual overview of media management, see "Media Management". To learn what you need to do to configure a media manager for use with RMAN, see "Configuring a Media Manager".

Enterprise Manager

Although RMAN is commonly used as a command-line utility, you can also perform RMAN backups using Oracle Enterprise Manager. Oracle Enterprise Manager-Backup Manager is a GUI interface to Recovery Manager that enables you to perform backup and recovery via a point-and-click method.

See Also: For information about performing backup and recovery using Oracle Enterprise Manager, see the Oracle Enterprise Manager Administrator's Guide.

Operating System (O/S)

You can perform an O/S backup with a native command on your O/S. For example, you can use the cp command to back up files in UNIX. In this case, you must write and maintain UNIX scripts to control the O/S backup.

See Also: For information about the utilities available on your operating system, see your operating system-specific documentation.

Export

The Oracle Export utility writes data from an Oracle database to operating system files in an Oracle-specific format. Export files store information about schema objects created for a database. Because the Oracle Export utility can selectively export specific objects, you may consider exporting portions of or all of a database for supplemental protection and flexibility. Database exports are not a substitute for whole database backups.

See Also: For information about using exports to supplement your backup strategy, see Oracle8i Utilities.

Enterprise Backup Utility

The Oracle Enterprise Backup Utility (EBU) is a utility that automates backups of Oracle7 databases; it is not compatible with Oracle8i databases.

Feature Comparison of Backup Methods

Table 3-2 compares the features of the backup methods described in this chapter:

Table 3-2 Feature Comparison of Backup Methods
Feature  Recovery Manager  Operating System  Export 

Closed database backups  

Supported. Requires instance to be mounted.  

Supported.  

Not supported.  

Open database backups  

Do not use BEGIN/END BACKUP commands.  

Use BEGIN/END BACKUP commands.  

Requires RBS to generate consistent backups.  

Incremental backups  

Supported.  

Not supported.  

Not supported.  

Corrupt block detection  

Supported. Identifies corrupt blocks and writes to V$BACKUP_CORRUPTION or V$COPY_CORRUPTION.  

Not supported.  

Supported. Identifies corrupt blocks in the export log.  

Automatic backup  

Supported. Establishes the name and locations of all files to be backed up (whole database, tablespace, datafile or control file backup).  

Not supported. Files to be backed up must be specified manually.  

Supported. Performs either full, user, or table backups.  

Backup catalogs  

Supported. Backups are cataloged in the recovery catalog and in the control file, or just in the control file.  

Not supported.  

Not supported.  

Backups to sequential media  

Supported. Interfaces with a media manager. RMAN also supports proxy copy, a feature that allows the media manager to manage the transfer of data.  

Supported. Backup to tape is manual or managed by a media manager.  

Supported.  

Backs up init.ora and password files  

Not supported.  

Supported.  

Not supported.  

Operating system independent language  

Supported.  

Not supported.  

Supported.  

Choosing Backup Formats

The format of your backup is contingent on the method you use to make it. You can back up files in the following formats:

Backup Sets

When you issue the RMAN backup command (and do not specify the proxy option), you create a backup set. A backup set is a logical structure containing one or more physical backup pieces. Typically, a backup set contains one backup piece. Backup sets can:

Backup sets are in an Oracle proprietary format, which means that an Oracle instance cannot use files in a backup set until RMAN restores them to an instance-usable format. For example, a tablespace backup in a backup set is a compressed version of each file in the tablespace; you must use an RMAN command to restore the datafiles in the backup set.

When you specify datafiles that you want to back up, an Oracle server session reads the files and creates the backup set. You do not need to precede an RMAN backup with the ALTER TABLESPACE BEGIN BACKUP statement (for information about how blocks are read in RMAN backups, see "Detection of Logical Block Corruption").

RMAN can include datafiles, control files, or archived redo logs in a backup set. If you perform a whole database backup, then RMAN automatically backs up every file in that database as well as the control file. You can also tell RMAN to include a control file backup in any datafile backup set.


Note:

You cannot combine archived redo logs and datafiles in the same backup set.  


See Also: For a conceptual overview of Recovery Manager backups, see "Backup Sets". To learn how to make RMAN backups, see Chapter 8, "Making Backups and Copies with Recovery Manager". For reference information for the RMAN backup command, see "backup".

Image Copies

Create an image copy using the RMAN copy command of any of the following objects:

When you issue the command, an Oracle server session--not an O/S routine--reads the file and writes the copy out to disk. You do not need to precede an RMAN copy with the ALTER TABLESPACE BEGIN BACKUP statement.

Image copies can be used immediately by an Oracle instance, i.e., they are already in an instance-usable format. You can only make image copies to disk.


Note:

You can make proxy copies to tape. Proxy copies are not image copies, but a type of media-managed backup generated with the proxy option of the backup command.  


See Also: For an overview of RMAN image copies, see "Image Copies". To learn how to make RMAN image copies, see "Making Image Copies". For information on the RMAN copy and backup commands, see "copy" and "backup".

Operating System Backups

Create operating system (O/S) backups using an operating system command such as the UNIX dd. You can write O/S backups to disk or tape in any format that your O/S utilities support. Recovery Manager can catalog and use O/S backups that are image backups on disk.

See Also: To learn how to make operating system backups, see Chapter 13, "Performing Operating System Backups".

Logical Backups

Logical backups store information about the schema objects created for a database. Use the Export utility to write data from an Oracle database to operating system files that have an Oracle database format.

Because the Oracle Export utility can selectively export specific objects or portions of an object, you can export portions or all of a database for supplemental protection and flexibility in a database's backup strategy. Database exports are not a substitute for physical backups and cannot provide the same complete recovery advantages that the built-in functionality of Oracle offers.

See Also: For more information about the Export Utility, see Oracle8i Utilities.

Developing a Backup Strategy

Before you create an Oracle database, decide how to protect the database against potential media failures. If you do not develop a backup strategy before creating your database, you may not be able to perform recovery should a disk failure damage the datafiles, online redo log files, or control files

This section describes general guidelines that can help you decide when to perform database backups and which parts of a database you should back up. Of course, the specifics of your strategy will depend on the constraints under which you are operating. No matter which backup strategy you implement, however, follow these guidelines whenever possible:

Decide Whether to Run in ARCHIVELOG or NOARCHIVELOG Mode

Before you create an Oracle database, decide how you plan to protect it against potential failures. Answer the following questions:

Once you have answered these questions and have determined which mode to use, follow the guidelines for either:

Backing Up in NOARCHIVELOG Mode

If you operate your database in NOARCHIVELOG mode, Oracle does not archive filled groups of online redo log files. Therefore, the only protection against a disk failure is the most recent whole backup of the database. Follow these guidelines:

Backing Up in ARCHIVELOG Mode

If you run your database in ARCHIVELOG mode, ARCn archives groups of online redo log files. Therefore, the archived redo log coupled with the online redo log and datafile backups can protect the database from a disk failure, providing for complete recovery from a disk failure to the instant that the failure occurred (or, to the desired non-current time). Following are common backup strategies for a database operating in ARCHIVELOG mode:

Multiplex Control Files, Online Redo Logs, and Archived Redo Logs

The control file, online redo log, and archived redo log are crucial files for backup and recovery operations. The loss of any of these files can cause you to lose data irrevocably. You should maintain:

See Also: To learn how to integrate data structure management into your backup and recovery strategy, see Chapter 2, "Managing Data Structures". For a thorough conceptual overview of all Oracle data structures, see Oracle8i Concepts.

Perform Backups Frequently and Regularly

Frequent backups are essential for any recovery scheme. Base the frequency of backups on the rate or frequency of database changes such as:

If users generate a significant amount of DML, database backup frequency should be proportionally high. Alternatively, if a database is mainly read-only, and updates are issued only infrequently, you can back up the database less frequently.

Use either Recovery Manager or O/S methods to create backup scripts. RMAN scripts, which are stored in the recovery catalog, are an especially efficient method for performing routine, repetitive backup operations.

See Also: For an overview of RMAN stored scripts, see "Stored Scripts". To learn how to create, delete, replace, and print stored scripts, see "Storing Scripts in the Recovery Catalog".

Perform Backups When You Make Structural Changes

Administrators as well as users make changes to a database. If you make any of the following structural changes, perform a backup of the appropriate portion of your database immediately before and after completing the alteration:

The part of the database that you should back up depends on your archiving mode:

Mode   Action  

ARCHIVELOG  

Make a control file backup (using the ALTER DATABASE statement with the BACKUP CONTROLFILE option) before and after a structural alteration. Of course, you can back up other parts of the database as well.  

NOARCHIVELOG  

Make a consistent whole database backup immediately before and after the modification.  

Perform Frequent Backups of Often-Used Tablespaces

Many administrators find that regular whole database backups are not in themselves sufficient for a robust backup strategy. If you run in ARCHIVELOG mode, then you can back up the datafiles of an individual tablespace or even a single datafile. This option is useful if a portion of a database is used more extensively than others, e.g., the SYSTEM tablespace and tablespaces that contain rollback segments. By making more frequent backups of the extensively used datafiles of a database, you gather more recent copies of the datafiles.

For example, you may make a whole database backup once a week on Sunday. If your database experiences heavy traffic during the week, a media failure on Friday can force you to apply a tremendous amount of redo data during recovery. If you had backed up your most frequently accessed tablespaces three times a week, you would have to apply a smaller number of changes to data to roll the restored file forward to the time of the failure.

Perform Backups After Unrecoverable/Unlogged Operations

If users are creating tables or indexes using the UNRECOVERABLE option, consider taking backups after the objects are created. When tables and indexes are created as UNRECOVERABLE, Oracle does not log redo data, which means that you cannot recover these objects from existing backups.


Note:

If using RMAN, you can take an incremental backup.  


See Also: For information about the UNRECOVERABLE option, see the CREATE TABLE ... AS SELECT and CREATE INDEX commands in the Oracle8i SQL Reference.

Perform Whole Database Backups After Using the RESETLOGS Option

After you have opened a database with the RESETLOGS option, Oracle recommends that you immediately perform a whole database backup. If you do not, and a disaster occurs, then you will lose all work performed since opening the database.

When you open a database with the RESETLOGS option, Oracle automatically:

Oracle performs these actions so that it can identify which archived redo logs apply to which incarnations of the database.

The resetting of the online redo logs has severe consequences for your backup and recovery strategy. As a rule, you cannot restore pre-RESETLOGS backups, so all your old backups are worthless in the new incarnation. The only exceptions are:

See Also: For more information, see "Recovering a Pre-RESETLOGS Backup".

Backup Options While in NOARCHIVELOG Mode

If you are operating in NOARCHIVELOG mode, your only option is to make a cold, consistent, whole database backup. If you do not, then your backups are inconsistent and require recovery before the database can be opened. Because no redo data is available for recovery, Oracle will prevent you from opening the database.

Backup Options in ARCHIVELOG mode

If you are operating in ARCHIVELOG mode, you can either perform a consistent, closed, whole database backup or an inconsistent, open database backup. The option you choose depends on:

If your most important criterion is getting the database up and running, then you must perform open database backups. You run a risk when you perform an open database backup--if the backups do not complete before you have another media failure, then you will lose all changes made since opening the database with the RESETLOGS option. You cannot use a backup taken before opening the database with RESETLOGS to recover this incarnation of the database.


Note:

There is one and only one exception to this rule. See "Recovering a Pre-RESETLOGS Backup".  


If the most important criterion is to restore in case of another failure, then you may elect to take a consistent, closed database backup. Oracle recommends that you perform a consistent whole database backup whenever possible.

Store Older Backups

You should store older backups for two basic reasons:

If you want to recover to a non-current time, you need a database backup that completed before the desired time. For example, if you make backups on the 1st and 14th of February, then decide at the end of the month to recover your database to February 7th, you must use the February 1st backup.

For a database operating in NOARCHIVELOG mode, the backup you use should be a consistent whole database backup. Of course, you will not be able to perform media recovery using this backup. For a database operating in ARCHIVELOG mode, your whole database backup:

For added protection, keep two or more database backups (with associated archived redo logs) previous to the current backup. Thus, if your most recent backups are not usable, you will not lose all of your data.


WARNING:

After you open the database with the RESETLOGS option, you cannot use existing backups for subsequent recovery beyond the time when the logs were reset. You should therefore shut down the database and make a consistent whole database backup. Doing so will enable recovery of database changes after using the RESETLOGS option.  


Know the Constraints for Distributed Database Backups

If your database is a node in a distributed database, all databases in the distributed database system should operate in the same archiving mode. Note the following consequences and constraints:

Mode   Constraint   Consequence  

ARCHIVELOG  

Closed cleanly.  

Backups at each node can be performed autonomously, i.e., individually and without time coordination.  

NOARCHIVELOG  

Closed cleanly.  

Consistent whole database backups must be performed at the same global time to plan for global distributed database recovery. For example, if a database in New York is backed up at midnight EST, the database in San Francisco should be backed up at 9 PM PST.  

See Also: To learn about performing media recovery in distributed systems, see "Opening the Database after Media Recovery".

Export Database Data for Added Protection and Flexibility

Because the Oracle Export utility can selectively export specific objects, consider exporting portions or all of a database for supplemental protection and flexibility in a database's backup strategy. This strategy is especially useful for recovery catalog backups when using RMAN.

Note that Database exports are not a substitute for whole database backups and cannot provide the same complete recovery advantages that the built-in functionality of Oracle offers.

See Also: For a complete account of the Export utility, see the Oracle8i Utilities guide.

Do Not Back Up Online Redo Logs

Although it may seem that you should back up online redo logs along with the datafiles and control file, this technique is dangerous. You should not back up online redo logs for the following reasons:

The danger in backing up online redo logs is that you may accidentally restore them while not intending to. There are a number of situations where restoring the online logs would cause very significant problems in the recovery process. Following are two scenarios that illustrate how restoring backed up online logs severely compromises recovery.

Scenario 1: Unintentionally Restoring Online Redo Logs

When a crisis occurs, it is easy to make a simple mistake. DBAs and system administrators frequently encounter dangers during a database restore. When restoring the whole database, it is also possible to accidentally restore the online redo logs, thus overwriting the current logs with the older, useless backups. This action forces the DBA to perform an incomplete recovery instead of the intended complete recovery, thereby losing the ability to recover valuable transactions contained in your overwritten redo logs.

Scenario 2: Erroneously Creating Multiple Parallel Redo Log Time Lines

You can unintentionally create multiple parallel redo log timelines for a single instance database. You can avoid this mistake, however, by making it so that the online logs cannot be restored. You must open the database with the RESETLOGS option, which effectively creates the new redo logs, and also a new database incarnation.

If you face a problem where the best course of action is to restore the database from a consistent backup and not perform any recovery, then you may think it is safe to restore the online logs and thereby avoid opening the database with the RESETLOGS option. If you do so, however, the database will eventually generate a log sequence number that was already generated by the database during the previous timeline.

If you then face another disaster and need to restore from this backup and roll forward, you will find it difficult to identify which log sequence number is the correct one. If you had reset the logs, then you would have created a new incarnation of the database. You could only apply archived redo logs created by this new incarnation to this incarnation.


Note:

Recovery Manager and EBU do not back up online redo logs.  


Developing a Recovery Strategy

Oracle provides a variety of procedures and tools to assist you with recovery. To develop an effective recovery strategy, learn to do the following:

Test Backup and Recovery Strategies

Practice your backup and recovery strategies in a test environment before and after you move to a production system. In this way you can measure the thoroughness of your strategies and minimize problems before they occur in a real situation. Performing test recoveries regularly ensures that your archiving, backup, and recovery procedures work. It also helps you stay familiar with recovery procedures, so that you are less likely to make a mistake in a crisis.

If you use Recovery Manager, use the duplicate command to create a test database using backups of your production database. To learn how to duplicate a database, see Chapter 10, "Creating a Duplicate Database with Recovery Manager".

Handling Non-Media Failures

Although media recovery is your primary concern when developing your recovery strategy, you should understand the basic types of non-media failures as well as the causes and solutions for each:

Statement Failure

A statement failure is a logical failure in the handling of a statement in an Oracle program. Oracle or the O/S usually returns an error code and a message when a statement failure occurs. Table 3-3 shows typical causes and resolutions for statement failures.

Table 3-3 Typical Causes and Resolutions for Statement Failures
Problem  Solution 

A logical error occurred in an application.  

Fix the program that generated the error so that its logic flows correctly. You may need to enlist the aid of developers to solve this type of problem.  

A user attempted to enter illegal data into a table.  

Modify the illegal SQL statement and reissue it.  

A user attempted an operation with insufficient privileges, e.g., attempting to insert data into a table when the user has only SELECT privileges.  

Provide the necessary database privileges for the user to complete the statement successfully.  

A user attempted to create a table but exceed the allotted quota limit.  

Issue an ALTER USER command to change the quota limit.  

A user attempted a table INSERT or UPDATE, causing an extent to be allocated without sufficient free space in the tablespace.  

Add space to the tablespace. You can also use the RESIZE and AUTOEXTEND options for datafiles.  

User Process Failure

A user process failure is any failure in a user program accessing an Oracle database. User processes can fail for a wide variety of reasons. Some typical scenarios include:

In most cases, you do not need to act to resolve user process failures: the user process simply fails to function but does not affect Oracle and other user process. The PMON background process is usually sufficient for cleaning up after an abnormally terminated user process.

User Error

Users errors are any mistakes that users make in adding data to or deleting data from the database. Typical causes of user error are:

If you have a logical backup of a table from which data has been lost, sometimes you can simply import it back into the table. Depending on the scenario, however, you will probably have to perform some type of incomplete media recovery to correct such errors.

You can perform either database point-in-time recovery (DBPITR) or tablespace point-in-time recovery (TSPITR). The following table explains the difference between these types of incomplete recovery:

Type   Description   Procedure  

DBPITR  

  1. Restore backup database.

  2. Roll forward to the time just before the error.

  3. Open RESETLOGS.

 

For RMAN recovery, see "Performing Incomplete Recovery".

For O/S recovery, see "Performing Incomplete Media Recovery".  

TSPITR  

  1. Create auxiliary instance.

  2. Recover the tablespace on the auxiliary to the time just before the error.

  3. Import data back into the primary database.

 

For RMAN TSPITR, see Appendix A, "Performing Tablespace Point-in-Time Recovery with Recovery Manager".

For O/S TSPITR, see Appendix B, "Performing Operating System Tablespace Point-in-Time Recovery".  

Instance Failure

Instance failure occurs when an instance abnormally terminates. An instance failure can occur because:

Fortunately, Oracle performs instance recovery automatically: all you need to do is start the database. Oracle automatically detects that the database was not shut down cleanly, then applies committed and uncommitted redo records in the redo log to the datafiles and rolls back uncommitted data. Finally, Oracle synchronizes the datafiles and control file and opens the database.

Recovering from Media Failure

Media failure is the biggest threat to your data. A media failure is a physical problem that occurs when a computer attempts to read from or write to a file necessary to operate the database. Common types of media problems include:

The technique you use to recover from media failure depends heavily on the type of media failure that occurred. For example, the strategy you use to recover from a corrupted datafile is different from the strategy for recovering from the loss of your control file.

The basic steps for media recovery are:

See Also: To learn how to perform media recovery using RMAN, see Chapter 9, "Restoring and Recovering with Recovery Manager". To learn how to perform media recovery using O/S methods, see Chapter 14, "Performing Operating System Recovery".

Determine Which Files to Recover

First, you need to determine what to recover. Some types of failure are obvious: for example, the hardware crashes and you need to recover the entire database. In other cases, a single datafile becomes corrupted. Often you can use the table V$RECOVER_FILE to determine what requires recovery.

Choose a Type of Recovery

When you perform media recovery, you choose either complete recovery or incomplete recovery. Following is a list of media recovery operations:

One important and special type media recovery is tablespace point-in-time recovery (TSPITR). TSPITR enables you to recover one or more tablespaces to a point-in-time that is different from the rest of the database.

The type of recovery method you use depends on the situation. Table 3-4 displays typical scenarios and strategies.

Table 3-4 Typical Media Failures and Recovery Strategies
Lost Files  Archiving Mode  Status  Strategy 

One or more datafiles  

NOARCHIVELOG  

Closed  

Restore whole database from a consistent database backup. The control file and all datafiles are restored from a consistent backup and the database is opened. All changes made after the backup are lost.

Note: The only time you can recover a database in NOARCHIVELOG is when you have not already overwritten the online log files that were current at the time of the most recent backup.  

One or more datafiles and an online redo log  

NOARCHIVELOG  

Closed  

Restore whole database from consistent backup. You will lose all changes made since the last backup.  

One or more datafiles and all control files  

NOARCHIVELOG  

Closed  

Restore whole database and control file from consistent backup. You will lose all changes made since the last backup.  

One or more datafiles  

ARCHIVELOG  

Open  

Perform tablespace or datafile recovery while the database is open. The tablespaces or datafiles are taken offline, restored from backups, recovered, and placed online. No changes are lost and the database remains available during the recovery.  

One or more datafiles and an online redo log required for recovery  

ARCHIVELOG  

Closed  

Perform incomplete recovery of the database up to the point of the lost online redo log.  

One or more datafiles and an archived redo log required for recovery  

ARCHIVELOG  

Open  

Perform TSPITR on the tablespaces containing the lost datafiles up to the point of the latest available redo log.  

One or more datafiles and/or all control files  

ARCHIVELOG  

Not open  

Restore the lost files from backups and recover the datafiles. No changes are lost, but the database is unavailable during recovery.  

One or more datafiles and/or all control files, as well as an archived or online redo log required for recovery  

ARCHIVELOG  

Not open  

Perform incomplete recovery of the database. You will lose all changes contained in the lost log and in all subsequent logs.  

Restore Backups of Datafiles and Necessary Archived Redo Logs

The method you use to restore backups depends on whether you use RMAN or O/S methods to back up your data. If you use RMAN, then issue a restore command and let RMAN take over the transfer of data. If you use O/S methods, then you need to identify which files need to be restored and manually copy the backups to their necessary location.

If the database is shut down and you restore one of the datafiles with a backup, either because of a media failure or because for some reason you want to recover the database to a non-current time, Oracle detects an inconsistency between the checkpoint SCN in the datafile headers and the datafile header checkpoint SCNs recorded in the control file at database open time. Oracle then selects the lowest checkpoint SCN recorded in the control file and datafile headers and asks you to begin media recovery starting from a specified log sequence number. You cannot open the database if any of the online datafiles needs media recovery.

There is only one case in which Oracle will tell you that you need to perform media recovery when you do not. If a tablespace is in hot backup mode because you issued the ALTER TABLESPACE ... BEGIN BACKUP command and the system crashes, then on the next startup Oracle will issue a message stating that media recovery is required. Media recovery is not really required here, however, since you did not restore a backup; in this case, avoid media recovery by issuing the ALTER DATAFILE ... END BACKUP command. Note that RMAN backups do not have this problem.

See Also: To learn how to restore backups using RMAN, see "Restoring Datafiles, Control Files, and Archived Redo Logs". To learn how to restore datafiles using O/S methods, see "Restoring Files".

Begin Media Recovery

You have a choice between two basic methods for recovering physical files. You can:

Obviously, the recovery method you choose is contingent on which backup method you use. For example, if you backed up your files using:

Recovering with RMAN

RMAN is a powerful tool that can aid in backup and recovery operations. Using RMAN for recovery allows you to:

See Also: For a conceptual overview of Recovery Manager recovery, see "Restoring Files" and "Media Recovery". To learn how to perform RMAN recovery, see Chapter 9, "Restoring and Recovering with Recovery Manager". For reference information for the RMAN recover command, see "recover".

Recovering with the SQL*Plus RECOVER Command

If you do not use RMAN, then you can use O/S methods to restore your backups and SQL*Plus commands to perform media recovery. You can use SQL*Plus commands to:

You can use three basic SQL*Plus commands for recovery:

Note that each of these is also a sub-clause of an ALTER DATABASE statement. Oracle recommends using the SQL*Plus RECOVER command rather than the ALTER DATABASE statement with the RECOVER clause. For more information about the SQL*Plus RECOVER command, see SQL*Plus User's Guide and Reference.

Each command uses the same criteria to determine whether files are recoverable. If Oracle cannot get the lock for a file it is attempting to recover, it signals an error. This signal prevents two recovery sessions from recovering the same file and prevents media recovery of a file that is in use. In each case you can recover a database, tablespace, or datafile.

See Also: To learn about the differences between the SQL ALTER DATABASE RECOVER and SQL*Plus RECOVER statements, see "Using Media Recovery Statements".




Prev

Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index