RMAN allows you to back up the entire database now as a copy image via the backup as copy command. In addition, RMAN allows you to easily switch over to these copy images during a recovery situation, speeding up your recoveries significantly. Let’s look at these new features in a bit more detail.
Using the RMAN backup as copy Command RMAN introduces the backup as copy command, which allows you to create file image copies of the database datafiles, rather than creating backup sets (which is the default). You can use this command for the following kinds of backups:
Examples of the use of these commands are shown here:
RMAN> backup as copy database plus archivelog;
The file backup copies are exact duplicates of the database datafiles, thus they are larger than normal RMAN backup sets. Backup copies can be made to any disk location (and only to disk) via the format parameter. You can also configure a default device for disk copies with the configure command (discussed in more detail shortly) or, if you have configured a flash recovery area (also covered shortly), RMAN will create your backup copies in that area.
NOTE -- An error will be generated if the datafiles are in backup mode during a backup copy.
RMAN Backup File Image Copies: The Up Side and the Down Side
So, what are the benefits of RMAN backup file image copies? As you will see later in this section, RMAN backup copies can reduce your mean time to recover significantly. Use of image copies comes with a price, however, chiefly the requirement for additional disk space to store the copies, as opposed to RMAN backup sets. Since copies are not compressed, each full database copy essentially requires that an amount of space equivalent to the size of your database be allocated.
Another risk with datafile copies is the fact that these copies are stored on disk by RMAN. This leads to a pretty obvious single point of failure that you will want to address in your overall backup and recovery scheme.
Configure the Default Device Type to Copy
Oracle Database 10g allows you to configure your default backup type to be a copy backup with the configure device type command, as shown here:
RMAN> Configure device type disk backup type to copy;
Fast Recovery Using RMAN Copies
Previously, if you wanted to restore a database from an RMAN backup, you had a couple of options. The first was to restore the backup-set pieces via RMAN and then recover the database. Even if the backup-set pieces were on disk, this could take a significant amount of time. The second option was to make RMAN copies of each individual datafile and then manually restore from those copies, or locate those copies on a different set of disks and then rename the datafiles from within Oracle Database 10g. This was time- and labor-intensive.
Oracle Database 10g allows you to create a backup copy of the database to a different disk location and then quickly switch over to that disk location via the switch database to copy RMAN command. When the switch database command is issued, RMAN resets the location of the datafiles in the control file to the location of the datafile backup copies previously made via RMAN. After this switch is complete, you then recover the database, using those copies. This method of recovering the database can significantly reduce the overall mean time to recover your database.
Note also that when you switch your database to your datafile copies, you effectively lose one backup of your database. Also, the entire database is then located in one file system, such as the flash recovery area, which can be problematic.
Use RMAN to Back Up the Current Control File
In Oracle Database 10g, RMAN offers a new command, backup current controlfile, which is effectively the same as the alter database backup controlfile command that you would issue from the SQL prompt. The result is a copy of the control file, stored in the location defined (e.g., a location defined via the format command, the default copy value, or the flash recovery area). RMAN also allows you to create a standby control file with the backup current controlfile for standby command. The backup controlfilecopy command allows you to create backups of previous control file copies.
Using the catalog and uncatalog Commands
Oracle Database 10g offers additional commands that allow you to manipulate the catalog entries of backup sets. The catalog command allows you to enter new backup set–related information into the catalog. RMAN will overwrite any preexisting catalog information that conflicts with the information being cataloged. This command can be handy if you need to move the location of your backup-set pieces. Here is an example of the use of this command:
RMAN> catalog backuppiece
The change backuppiece uncatalog command will remove backup-set pieces from the catalog. If the change backuppiece uncatalog command removes the last remaining backup-set piece, then it will also remove the backup-set record. Here is an example of using the change backuppiece uncatalog command:
RMAN> Change backuppiece '/u01/oracle/RMAN/mydb/mydb_user01_01.bak' uncatalog;
One of the nice uses of the catalog command is to allow you to catalog moved backup-set pieces. If you have moved a large number of backup-set pieces, then it can be a great deal of work to generate a bunch of catalog statements to catalog the moved pieces. Instead, you can use the catalog command with the start with option. The start with option allows you to define the directory that contains the RMAN backup-set pieces to be cataloged. RMAN will then catalog all backup-set pieces in that directory. Here is an example of using the catalog command this way:
RMAN> catalog start with '/u01/oracle/RMAN/mydb';
Once you press ENTER, this command prompts you with a list of files to catalog, and asks if you wish to catalog the files listed. If you respond in the affirmative, RMAN catalogs all the backup-set pieces listed (which will be contained in the /u01/oracle/RMAN/mydb directory). This command also allows you to catalog several like-named backup-set pieces. For example, if you want to catalog several backup-set pieces that start with the name backup (e.g., backupset01, backupset02, etc.), then you could issue the following command:
RMAN> catalog start with '/u01/oracle/RMAN/mydb/backup';
When you use the catalog start with command, it is indiscriminate about the files it tries to catalog; it will try to catalog everything that matches the argument list. However, as the catalog process proceeds, files that are not backup-set pieces will fail the catalog process and an error will occur. Files that are backup-set pieces will be cataloged successfully, in spite of other errors.
Dropping a Database in RMAN
In Oracle Database 10g, RMAN provides the capability to drop a database to remove all physical database files, by using the drop database command. To drop the database, first log in to the database to be dropped. Then, make sure the database is mounted in exclusive mode, but is not open. Finally, issue the drop database command. If you also want to remove all RMAN database-related backups (but not recovery catalog information), you can include the including backups option when you issue the drop database command. Here is an example call:
Unregistering a Database in RMAN
Prior to Oracle Database 10g, unregistering a database from the recovery catalog was a manual process. Now, Oracle Database 10g makes removing a database from the recovery catalog as easy as issuing the command unregister database. Here is an example:
RMAN> Unregister database mydb;
Note that the backup files for this database, and any associated control file records, are not deleted by this command; only the recovery catalog references to those backup files are deleted. Also note that you only need to be connected to the recovery catalog to issue this command.
blog comments powered by Disqus