RelationalDBDesign RelationalDBDesign


Managing File Copies   «Prev  Next»
Lesson 2Types of Backups
ObjectivePerform online and offline Backups

Types of Database Backups in Oracle

You can create a backup while the target database is still operating or when the database is closed down. These two circumstances are called online and offline, respectively.

Online backups

Oracle gives you the ability to perform backups while the target database is still being used. To perform an online backup, also known as a hot backup, your Oracle database must be running in ARCHIVELOG mode. ARCHIVELOG mode ensures that the all -important log files are not deleted when they no longer contain active transactions.
If you are attempting to perform an online backup outside of the Oracle environment-that is, without using Recovery Manager, you must issue the command
ALTER TABLESPACE tablespace_name 
BEGIN BACKUP
before beginning the online backup, and the command
ALTER TABLESPACE tablespace_name 
END BACKUP
at the end of the backup. In between these two commands, Oracle knows to write extra information to the redo log to correct the situation during the recovery process.
Because Recovery Manager is an internal Oracle process, you can do online backups with RMAN without issuing any additional commands.

Online Backups and Backup Mode

When performing a user-managed backup of an online tablespace or database, an operating system utility can back up a data file at the same time that the database writer (DBWR) is updating the file. It is possible for the utility to read a block in a half-updated state, so that the block that is copied to the backup media is updated in its first half, while the second half contains older data. This type of logical corruption is known as a fractured block, that is, a block that is not consistent with an SCN[1].

Oracle Backup and Recovery
If this backup must be restored later, and if the block requires recovery, then recovery fails because the block is not usable. When performing a user-managed online backup, you must place your datafiles into backup mode with the ALTER DATABASE or ALTER TABLESPACE statement with the BEGIN BACKUP clause.
When a tablespace is in backup mode, the database writes the before image for an entire block to the redo stream before modifying a block. The database also records changes to the block in the online redo log. Backup mode also freezes the data file checkpoint until the file is removed from backup mode. Oracle Database performs this safeguard because it cannot guarantee that a third-party backup tool copies the file header before copying the data blocks. Unlike user-managed tools, RMAN does not require extra logging or backup mode because it knows the format of data blocks. RMAN is guaranteed not to back up fractured blocks. During an RMAN backup, a database server session reads each data block and checks whether it is fractured by comparing the block header and footer. If a block is fractured, then the session rereads the block. If the same fracture is found, then the block is considered permanently corrupt. Also, RMAN does not need to freeze the data file header checkpoint because it knows the order in which the blocks are read, which enables it to capture a known good checkpoint for the file.

Offline backups

When you perform an offline backup, the Oracle database does not have to deal with any of the problems mentioned above. If the database was shut down normally, you can use an offline backup to restore the database without having to apply any redo logs to the database. Because the database is closed, no redo logs are associated with it.
In the next lesson, we will review the different formats for backups.

Performing Offline Database Backups

When performing an offline backup, the database instance shuts down, then restarts and enters a MOUNTED state for the duration of the offline backup. The offline backup runs in the background, generating no user-visible output in the browser. The fact that the database is not open affects the pages you see from Enterprise Manager while the offline backup runs. After you submit the backup job, a status page should appear indicating that the job has been successfully submitted. The output also includes a notification that the database will be shut down and mounted as part of the offline backup, and that you must wait for the backup to complete. When the database is shut down and restarted, the Enterprise Manager application must also shut down for a brief time. During the period when Enterprise Manager is shut down, it cannot respond to attempts to refresh the page. After Enterprise Manager restarts but the database is not open, Enterprise Manager reports that it cannot connect to the instance. The Database Instance section of the page reports the current state of the database listener and the instance (unmounted or mounted) as the database performs the offline backup. It also offers the options of Startup or Perform Recovery.

[1] (SCN) system change number is a logical, internal time stamp used by Oracle Database. SCNs order events that occur within the database, which is necessary to satisfy the ACID properties of a transaction. Oracle Database uses SCNs to mark the SCN before which all changes are known to be on disk so that recovery avoids applying unnecessary redo. The database also uses SCNs to mark the point at which no redo exists for a set of data so that recovery can stop. SCNs occur in a monotonically increasing sequence. Oracle Database can use an SCN like a clock because an observed SCN indicates a logical point in time and repeated observations return equal or greater values. If one event has a lower SCN than another event, then it occurred at an earlier time with respect to the database. Several events may share the same SCN, which means that they occurred at the same time with respect to the database.