• Identify the types of flash recovery area files.
• Define the types of database backups. Describe how to back up control files.
• Understand how to create consistent, inconsistent, and incrementally updated backups.
• Know the steps to manage database backups.
Focused Explanation
The Flash Recovery Area
The flash recovery area is a storage area used for the recovery of a database. The flash recovery area can be a single directory, a file system, or an Automatic Storage Management (ASM) disk group. The flash recovery area contains the following types of files:
• control files
• archived log files
• Recovery Manager (RMAN) backup sets
• flashback logs
• control file and server parameter file (SPFILE) autobackups
• datafile copies
You can create the flash recovery area using SQL statements or using Enterprise Manager Database Control.
Creating the Flash Recovery Area using SQL Statements
You can create the flash recovery area by configuring two initialization parameters,
DB_RECOVERY_FILE_DEST_SIZE and DB_RECOVERY_FILE_DEST using SQL statements. The DB_RECOVERY_FILE_DEST_SIZE parameter specifies the size of the flash recovery area. The
DB_RECOVERY_FILE_DEST initialization parameter specifies the physical location of all the flash recovery files. You need to configure the DB_RECOVERY_FILE_DEST_SIZE initialization parameter before
configuring the DB_RECOVERY_FILE_DEST initialization parameter. To configure the
DB_RECOVERY_FILE_DEST_SIZE initialization parameter and specify the size of the flash recovery area as 8 GB, type the following statement at the SQL prompt:
SQL> ALTER SYSTEM
2 SET DB_RECOVERY_FILE_DEST_SIZE=8G SCOPE=BOTH;
To configure the DB_RECOVERY_FILE_DEST initialization parameter and specify that the flash recovery files are stored in the ORADIR directory, type the following statement at the SQL prompt:
SQL> ALTER SYSTEM
2 SET DB_RECOVERY_FILE_DEST = ‘\ORADIR’ SCOPE=BOTH;
Creating the Flash Recovery Area Using Enterprise Manager Database Control
You can also create the flash recovery area using Enterprise Manager Database Control. To create the flash recovery area using Enterprise Manager Database Control, complete the following steps:
1. Open the Database Home page of Enterprise Manager Database Control.
2. Click the Maintenance tab on the Database Home page. The Maintenance tab page is displayed.
3. Click the Configure Recovery Settings link. The Configure Recovery Settings page is displayed.
4. Scroll down to display the Flash Recovery Area pane on the Configure Recovery Settings page.
Figure 10-1 shows the Flash Recovery Area pane.
Figure 10-1: The Flash Recovery Area Pane The following text boxes are displayed in the Flash Recovery Area pane:
• Flash Recovery Area Location – Specifies the physical location where all the flash recovery files are stored.
• Flash Recovery Area Size – Specifies the size of the flash recovery area.
5. Type the location at which you want to store flash recovery area files, in the Flash Recovery Area Location text box.
6. Type the size of the flash recovery area in the Flash Recovery Area Size text box.
7. Click the Apply button to apply the changes.
Types of Database Backups
The following are the types of database backups:
• Whole backup – Creates a backup of all the datafiles and at least one control file. In whole backups, online redo log files are not backed up.
• Partial backup – Creates a backup of one or more tablespaces. The following are the types of partial backups:
o Tablespace backup – Creates backups of the tablespace containing datafiles. You can perform tablespace backups of a database when the database is in the ARCHIVELOG mode. If you are creating a backup of the database that is running in the NOARCHIVELOG mode, the tablespace that you want to back up should be read-only.
o Datafile backup – Performs backups of a single datafile. You can perform datafile backup of a database when it is in the ARCHIVELOG mode. You can perform datafile backup of a database in the NOARCHIVLOG mode if the datafile you want to back up is read-only or is the only file in a tablespace.
o Control File backup – Performs a backup of a control file of a database. You can create the backup of a control file using the ALTER DATABASE BACKUP CONTROLFILE statement. You can also use the CONFIGURE CONTROLFILE AUTOBACKUP RMAN command to create a backup of a control file.
o Archived Redo Log backup – Performs recovery of an inconsistent backup. You can create a backup of archived redo log files using the BACKUP ARCHIVELOG RMAN command.
• Full backup – Creates a backup of all the data blocks in every datafile in a database.
• Incremental backup – Creates a copy of the data in a database that has changed since the previous backup. There are five levels of incremental backups supported by Oracle 10g, starting from 0 to 4. The level 0 backup, referred to as a baseline backup, contains the backup of all data blocks in the datafiles that are backed up. Level 1 backs up files that changed since the last level 0 backup, level 2 backs up files that changed since the last level 1 backup, and so on. You should create this type of backup, when you want to back up only the changes recently made to a database.
• Consistent backup – Creates a backup when a database is closed and is not available to a user.
A consistent backup is also called an offline backup. When consistent backups are performed, the SCN in a control file matches with the SCN in the header of the corresponding datafile. If you create a consistent backup of a database operating in the NOARCHIVELOG mode, you should recover the database for consistency because the database in the NOARCHIVELOG mode does not archive redo log files. You should create this type of backup, when you want the database and the backup to be consistent.
• Inconsistent backup – Creates a backup when a database is open. When inconsistent backups are performed, the SCN in a control file does not match with the SCN in the header of the corresponding datafile. If a database runs 24 hours a day and seven days a week, you should perform inconsistent database backups. The inconsistent backup is also called an online backup.
Backing up Control Files
You can back up control files to prevent the loss of all control files of a database. TheUSER_DUMP_DEST initialization parameter is used to specify the directory in which control files are backed up. The format of the names of the backup control files issid_ora_pid.trc,wheresidspecifies the session ID,pid specifies the process ID of the user creating the backup. The file extension .trc represents that the file is an editable text file.
A control file is backed up to trace when the structure of the database changes, such as adding or dropping a tablespace or creating a new redo log file group. You can backup control files using SQL statements. Type the following SQL statement at the SQL prompt to create a backup control file as a trace file:
SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
You can also back up the control files by making a binary copy of the control files. Type the following statement at the SQL prompt to create a backup of the control file:
SQL> ALTER DATABASE BACKUP CONTROLFILE TO ‘\U03\ORADATA\CTLFILE20040911.BKP’;
Creating Consistent Database Backups
To create a consistent database backup, complete the following steps:
1. Shut down the database you want to back up in the NORMAL, IMMEDIATE, or TRANSACTIONAL mode.
2. Search for*.ora in the Oracle home directory to locate the initialization parameter file. Copy the
*.ora files on DISK1, to another disk, DISK2, by typing the following command at the command prompt:
COPY \DISK1\ORACLE\NETWORK\ADMIN\*.ORA \DISK2\BACKUPS
This command creates a backup of the initialization parameter file on DISK1, to the BACKUPS directory of DISK2.
3. Create the backups of all the datafiles and control files by typing the following commands at the command prompt:
COPY $ORACLE_HOME\ORADATA\TRGT\*.DBF \DISK2\BACKUP
COPY $ORACLE_HOME\ORADATA\TRGT\ARCH\* \DISK2\BACKUP\ARCH
These commands create the backups of all the datafiles and control files to directories on DISK2.
4. Restart the database using the following SQL statement:
SQL> STARTUP
Creating Inconsistent Database Backups
To create inconsistent database backups, complete the following steps:
1. Identify all the datafiles of a tablespace using the following SQL statement:
SQL> SELECT TABLESPACE_NAME,FILE_NAME FROM SYS.DBA_DATA_FILES 2 WHERE TABLESPACE_NAME=‘USERS’;
2. Start the backup of the tablespace using the following SQL statement:
SQL> ALTER TABLESPACE USERS BEGIN BACKUP;
3. Backup the online datafiles of the tablespace by typing the following commands at the command prompt:
COPY \ORACLE\ORADATA\TRGT\USERS1.DBF \C\USERS1_
COPY \ORACLE\ORADATA\TRGT1\USERS2.DBF \C\USERS2_
These commands create backup copies of the datafiles of the tablespace USERS1 and USERS2. The commands copy the datafiles from the TRGT and TRGT1 directories of ORADATA to directories USER1 and USER2, respectively.
4. End the backup of the online tablespace using the following SQL statement:
SQL> ALTER TABLESPACE USERS END BACKUP;
5. Archive the unarchived redo log files using the following SQL statement:
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
Creating Incremental Backups
The backup process in Oracle 10g uses RMAN to create incremental backups. The following RMAN command is used to create the baseline level 0 backup, which backs up an entire database:
RMAN> BACKUP INCREMENTAL LEVEL 0
2 AS COMPRESSED BACKUPSET DATABASE;
This command backs up the database using compression to save disk space.
The following RMAN command is used to create a level 1 backup:
RMAN> BACKUP INCREMENTAL LEVEL 1
2 AS COMPRESSED BACKUPSET DATABASE;
Creating Incrementally-Updated Backups
You can also create incrementally-updated backups, which use incremental backups and back up the entire image copy by updating the changed blocks in the existing image copy. Execute the following RMAN script at the RMAN prompt to create an incrementally-updated backup:
RUN {