| Oracle&r
eg; Database Backup and Recovery Basics 10g Release 1 (10.1) Part Number B10735-01 |
|
|
View PDF |
This chapter provides a general overview of backup and recovery concepts, the files in an Oracle database related to backup and recovery, and the tools avail able for making backups of your database, recovering from data loss or other error, and maintaining records of your backups.
This chapter includes the following topics:
In general, backup and recovery refers to the various strategies and procedures involved in protect ing your database against data loss and reconstructing the database after any kind of data loss.
A backup is a copy of data from your database that can be used to reconstruct that data. Backups can be div ided into physical backups and logical backups.
Physical backups are backups of the physical files used in storing and recovering your database, such as datafiles, control files, and archived redo logs. Ultimately, every physical backup is a copy of files storing database information to some othe r location, whether on disk or some offline storage such as tape.
Logical backups contain l ogical data (for example, tables or stored procedures) exported from a database with an Oracle export utility and stored in a binary file, for later re-importing into a database using the corresponding Oracle import utility..
| See also:
Oracle Database Utilities for more details about importi ng and exporting data using Oracle export and import utilities. |
Physical backups are the foundation of any sound backup and recovery strategy. Logical backups are a useful supplement to phy sical backups in many circumstances but are not sufficient protection against data loss without physical backups.
Unless otherwise specified, the term "backup" as used in the backup and recovery documentation refers to physi cal backups, and to backup part or all of your database is to take some kind of physcial backup. The fo cus in the backup and recovery documentation set will be almost exclusively on physical backups.
While there are several types of problem that can halt the nor mal operation of an Oracle database or affect database I/O operations, only two typically require DBA intervention and media recovery : media failure, and user errors.
Other failures may require DBA intervention to restart th e database (after an instance failure) or allocate more disk space (after statement failure due to, for instance, a full datafile) bu t these situations will not generally cause data loss or require recovery from backup.
User errors occur when, either due to an error in application logic or a manual mis-step, data in your database is changed or deleted incorrectly. Data loss due to user error includes such missteps as dropping important tables or deleting or cha nging the contents of a table. While user training a nd careful management of privileges can prevent most user errors, your backup st rategy determines how gracefully you recover the lost data when user error does cause data loss.
A media failure is the failure of a read or write of a disk file required to run the database, due to a physical problem with the disk such as a head crash. Any database file can be vulnerable to a media failure.
The appr opriate recovery from a media failure depends on the files affected and the types of backup available.
For performing backup and recovery based on physical backups, you have two solutions available:
Both methods are supported by Oracle Corporation and are fully documented. Recovery Manager is, however, the preferred solution fo r database backup and recovery. It can perform the same types of backup and recovery available through user-managed methods more easi ly, provides a common interface for backup tasks across different host operating systems, and offers a number of backup techniques no t available through user-managed methods.
Most of the backup and recovery documentation set will focus on RMAN-based backup and recovery. User-managed backup and recovery techniques are covered in the later chapters of Oracle Database Backup and Recovery Advanced User's Guide.
Whether you u se RMAN or user-managed methods, you can supplement your physical backups with logical backups of schema objects made using data expo rt utilities. Data thus saved can later be imported to re-create this data after restore and recovery. However, logical backups are f or the most part beyond the scope of the backup and recovery documentation.
The physical structures of the database and the role each plays in the data base recovery process are what determine the forms of backup and recovery available through user-managed techniques and through RMAN.
The files and other structures that make up an Oracle database store data and safeguard it against possible failures. This section in troduces each of the physical structures that make up an Oracle database and their role in the reconstruction of a database from back up. This section contains these topics:
An Oracle database consists of one or more logical storage units called tablespaces. Each tablespace in an Or acle database consists of one or more files called datafiles, physical files under the host operating system in which the database is running.
A database's data is collectively stored in the datafiles that constitute each ta blespace of the database. The simplest Oracle database would have one tablespace, stored in one datafile. The datbase manages the sto rage space in the datafiles of a database in units called data blocks. A data block is the smallest unit of data used by a database. Data blocks are the smallest units of storage that the database can use or allocate.
Modifi
ed or new data is not written to datafiles immediately. Updates are buffered in memory and written to datafiles at intervals. If a da
tabase has not gone through a normal shutdown (that is, if it is open, or exited abnormally, as in an instance failure or a SHU
TDOWN ABORT) then there are typically changes in memory that have not been written to the datafiles. Datafiles that were resto
red from backup, or were not closed during a consistent shutdown, are typically not completely up to date.
Copies of the datafiles of a database are a c ritical part of any backup.
| See also:
Oracle Database Concepts for more detail about the structure and contents of datafiles and data blocks. |
Redo logs record all changes made to a database's data files. With a complete set of redo logs and an older copy of a datafile, the databa se can reapply the changes recorded in the redo logs to re-create the database at any point between the backup time and the end of th e last redo log. Each time data is changed in the database, that change is recorded in the online redo log first, before it is applied to the datafiles. An Oracle d atabase requires at least two online redo log group strong>s, and in each group there is at least one online redo log member, an individual redo log file where the changes a re recorded.
At intervals, the database rotates through the online redo log groups, storing changes in the current online redo log while the groups not in use can be copied to an archive location, where they are called archive d redo logs (or, collectively, the archived redo log). You can run your database in ARCHIVELOG mode (in which this archiving of redo log files is enabled) or NOARCHIVELOG mode (in w hich redo log files are simply overwritten).
Preserving the archived redo log is a major pa rt of most backup strategies, as they contain a record of all updates to datafiles. Backup strategies often involve copying the archi ved redo logs to disk or tape for longer-term storage. Running in NOARCHIVELOG mode limits your data recovery options.
Oracle Database Administrator's Guide for more details about the online redo logs, Oracle Database Administrator's Guide for more details about archived redo logs, and "Deciding Between ARCHIVELOG and NOARCHIVELOG Mode" for a discussion of the implic ations of archiving or discarding your redo log files. |
The control file contains a crucial record of the physical structures of the database and their status. Se veral types of information stored in the control file are related to backup and recovery:
The recovery process for datafiles is in part guided by status information in the control file, such as the database checkpoints, current online redo log file, and the datafile header checkpoints for the datafi les. Loss of the control file makes recovery from a data loss much more difficult.
| See also:
Oracle Database Concepts for more information about control files. |
|
Note: If only one tablespace is affected by the data loss, you have the option of performing point-in-time recovery on that tablespace instead of the entire databas e. Tablespace point-in-time recovery (often abbreviated TSPITR) is an advanced technique documented in Oracle Database Backup and Recovery Advanced User's Guide. |
The crash recovery process is a special form of recovery, which happens the first time an Oracle database instance is started after a crash (or SHUT
DOWN ABORT). In crash recovery, the goal is to bring the datafiles to a transaction-consistent state, preserving all committed
changes up to the point when the instance failed.
Unlike the forms of recovery performed m anually after a data loss, crash recovery uses only the online redo log files and current online datafiles, as left on disk after the instance failure. Archived logs are never used during crash recovery, and datafiles are never restored from backup.
The database applies any pending updates in the online redo logs to the online datafiles of your database. The result is that, whenever the database is restarted after a crash, the datafiles reflect all committed changes up to the moment wh en the failure occurred. (After the database opens, any changes that were part of uncommitted transactions at the time of the crash a re rolled back.)
The duration of crash recovery is a function of the number of instances ne eding recovery, amount of redo generated in the redo threads of crashed instances since the last checkpoint, and user-configurable fa ctors such as the number and size of redo log files, checkpoint frequency, and the parallel recovery setting.You can set parameters i n the database server that can tune the duration of crash recovery. You can also tune checkpointing to optimize recovery time.
As noted earlier, using RMAN gives you access to several data backup and recovery techniques and features not available at all with user-managed backup and recovery. The most noteworthy are:
A complete list of feature differences between RMAN and user-managed backup and recovery can be found in "Feature Comparison of Backup Methods" .
RMAN also reduces the administration work associated with your backup strategy. RMAN keeps an extensive record of metadata about backups, archived logs, and its own activities, known as the RMAN repository. In restore operations, RMAN can use this information to eliminate the need for you to identify backup files for use in restores in most situations. You can also generate reports of backup activity using the informat ion in the repository.
Primary storage for RMAN repository information is in the control fi le of the production database. You can also set up an independent recovery catalog, a schema that stores RMAN repository information for one or many databases in a separate recovery catalog database.
The remainder of this book, Oracle Database Backup and Recovery Bas ics, focuses on using RMAN to implement your backup and recovery strategy.
There are several ways of distinguishing among physical backups, according to the state the database was in when the backup was created, what parts of the database were actually backed up, and how the resulting backup wa s stored.
Physical backups can also be di
vided into consistent and inconsistent backups. Consistent backups are th
ose created when the database is in a consistent state, that is, when all changes in the redo log have been applied to the datafiles.
A database restored from a consistent backup can be opened immediately, without undergoing media recovery. However, a consistent bac
kup can only be created after the database has been shut down normally, that is, not after a crash or a SHUTDOWN ABORT.<
/p>
For reasons of availability, the Oracle database is designed to work equally well with an i
nconsistent backup, a backup taken while the database is open. When a database is restored from an inconsistent backup, it must under
go media recovery, so that the database can apply any pending changes from the online and archived redo log before the database is op
ened again. Because archived logs are required, using inconsistent backups requires that your database be run in ARCHIVELOG mode.
Full backups are backups which include datafiles in their entirety. Full backups can be created with Recovery Manager or with operating system-level file copy commands. In cremental backups are based on the idea of making copies only of changed data blocks in a data file. In recovery, extracting entire c hanged blocks from an incremental backup can substitute for applicationof redo for individual datafile updates during the time covere d by the backup, shortening recovery times considerably. Incremental backups can only be created with RMAN.
| See Also:
"Full and Incremental Datafile Backups" for more details about the different ways to back up datafiles. |
The results of an Oracle database backup created through RMAN can be either image copies or backup sets. An image copy is a bit-for-bit identical copy of a database file. These can be created using operating system
commands such as cp in Unix or COPY in Windows. RMAN can also create image copy backups, although in the p
rocess, RMAN will check the contents for corruption, something that native operating-system file copy utilities cannot do. RMAN recor
ds image copies it creates in the RMAN repository, so that it can use them when restoring your database. If you create image copies o
utside of RMAN, you can catalog them manually into the RMAN repository.
RMAN can also store its backups in an RMAN-exclusive format called a backup set. A backup set is a collection of f iles called backup pieces, each of which may contain the backup of one or several database file s. A backup task performed in RMAN can create one or more backup sets, which are recorded in the RMAN repository. Backup sets are als o the only form in which RMAN can write backups to media manager devices like tape libraries. Backup sets are only created and access ed through Recovery Manager.
In planning your database backup and recovery strategy, you must try to anticipate the errors that will arise, and put in place the backups needed to recover from them.While there are sever al types of problem that can halt the normal operation of an Oracle database or affect database I/O operations, only two typically re quire DBA intervention and media recovery: media failure, and user errors. Instance failures, network failures, failures of Oracle da tabase background processes and failure of a statement to execute due to, for instance, exhaustion of some resource such as space in a datafile may require DBA intervention, and might even crash a database instance, but will not generally cause data loss or the need to recover from backup.
This section contains these topics:
Datab ase operation after a media failure of online redo log files or control files depends on whether the online redo log or control file is protected by multiplexing, a s recommended. When an online redo log or control file is multiplexed, multiple copies of the file are maintained on the system. Mult iplexed files should be stored on separate disks.
If a media failure damages a disk contain ing one copy of a multiplexed online redo log, then the database can usually continue to operate without significant interruption. Da mage to a nonmultiplexed online redo log causes database operation to halt and may cause permanent loss of data.
Damage to any control file, whether it is multiplexed or not, halts database operation when the database attemp ts to read or write to the damaged control file (which happens frequently, for example at every checkpoint and log switch).
Media failures that affect datafiles can be divided into two categories: read e rrors and write errors. In a read error, the instance cannot read a datafile and an operating system error is returned to the application, along with an error indicating that the file cannot be found, cannot be opened, or canno t be read. The database continues to run, but the error is returned each time an unsuccessful read occurs. At the next checkpoint, a write error will occur when the database attempts to write the file header as part of the standard checkpoint process.
The effect of a datafile write error depends upon which tablespace the datafile is in.
If the instance cannot write to a datafile in the
SYSTEM tablespace, an undo tablespace (if the database is in
automatic undo management mode, which is the preferred choic
e in Release 10g), or a datafile in a tablespace containing active rollback segments (if in manual undo management mode), then the database issues an error and shuts down the instance. All files in the SYST
EM tablespace and all datafiles containing rollback segments must be online in order for the database to operate properly.
If the instance cannot write to a datafile other than those in the preceding list, then the re
sult depends on whether the database is running in ARCHIVELOG mode or not.
In
ARCHIVELOG mode, the database records an error in the database writer trace file and takes the affected datafile offline
. (All other datafiles in the tablespace containing this datafile remain online.) You can then rectify the underlying problem and res
tore and recover the affected tablespace.
In NOARCHIVELOG mode, the database w
riter background process DBWR fails, and the instance fails, the cause of the problem determines the required response. If the proble
m is temporary (for example, a disk controller was powered off), then crash recovery usually can be performed using the online redo l
og files. In such situations, the instance can be restarted without resorting to media recovery. However, if a datafile is permanentl
y damaged, then you must restore a consistent backup<
/strong> of the database.
Reco very is not needed on any read-only tablespace during crash or instance recovery. During startup, recov ery verifies that each online read-only datafile does not need media recovery. That is, the file was not restored from a backup taken before it was made read-only. If you restore a read-only tablespace from a backup taken before the tablespace was made read-only, th en you cannot access the tablespace until you complete media recovery.
Typically, a user error like dropping a table or deleting rows from a table requires one of the following responses:
The recovery options available to you will be a functi on of your backup strategy. For example, if you are running in NOARCHIVELOG mode then you have limited point-in-time recovery options .
See Also:
|
The components that creates differ ent backup and recovery-related files have no knowledge of each other or of the size of the file systems where they store their data. With Automatic Disk-Based Backup and Recovery, you can create a flash recovery area, which automates management of backup-related fi les. Choose a location on disk and an upper bound for storage space, and set a retention policy that governs how long backup files ar e needed for recovery, and the database manages the storage used for backups, archived redo logs, and other recovery-related files fo r your database within that space. Files no longer needed are eligible for deletion when RMAN needs to reclaim space for new files. I f you do not use a flash recovery area, you must manually manage disk space for your backup-related files and balance the use of spac e among the different types of files. Oracle Corporation recommends that you enable a flash recovery area to simplify your backup man agement.
When choosing a backup and recovery solution, find one that is appropriate for the database environment. For example, if you manage only databases of release 8.0 or higher, then you can use RMAN to manage your backup and recovery requirements. Releases older than 8.0 will have to b e managed using some method besides RMAN.
Table 1-1 de scribes the version and system requirements for different database backup and recovery methods.
| Backup Method | Type | Version Available | Requirements |
|---|---|---|---|
|
Recovery Manager (RMAN) |
<
a name="1005181">
Physical |
Oracle version 8.0 an d higher |
Third-party media manager (only if backing up to tape) |
|
Operating System |
Physical |
All versions |
Operating system backup utility (for example, UN
IX |
|
Export |
Logical |
All versions |
N/A |