Thursday, January 1, 2015

RMAN - Catalog Backups


How to catalog and uncatalog a backup to RMAN repository

Catalog Backup
 

Whenever we take any backup through RMAN, in the repository information of the backup is recorded. The RMAN respository can be either controlfile or recovery catalog. However if I take a backup through OS command then RMAN does not aware of that and hence recorded are not reflected in the repository. This is also true whenever we create a new controlfile or a backup taken by RMAN is transferred to another place using OS command then controlfile/recovery catalog does not know about the prior backups of the database. So in order to restore database with a new created controlfile we need to inform RMAN about the backups taken before so that it can pick one to restore.

This task can be done by catalog command in RMAN. With catalog command it can

-Add information of backup pieces and image copies in the repository that are on disk.
-Record a datafile copy as a level 0 incremental backup in the RMAN repository.
-Record of a datafile copy that was taken by OS.

But CATALOG command has some restrictions. It can't do the following.

-Can't catalog a file that belong to different database.
-Can't catalog a backup piece that exists on an sbt device.

Examples of Catalog command
1)Catalog an archive log: To catalog two archived logs named /oracle/oradata/arju/arc001_223.arc and /oracle/oradata/arju/arc001_224.arc the command is,

RMAN>CATALOG ARCHIVELOG '/oracle/oradata/arju/arc001_223.arc', '/oracle/oradata/arju/arc001_224.arc';

2)Catalog a file copy as an incremental backup: To catalog datafile copy '/oradata/backup/users01.dbf' as an incremental level 0 backup your command will be,


RMAN>CATALOG DATAFILECOPY '/oradata/backup/users01.dbf' LEVEL 0;


Note that this datafile copy was taken backup either using the RMAN BACKUP AS COPY command, or by using operating system utilities in conjunction with ALTER TABLESPACE BEGIN/END BACKUP.

3)Catalog multiple copies in a directory: To catalog all valid backups from directory /tmp/backups issue,

RMAN>CATALOG START WITH '/tmp/backups' NOPROMPT;

4)Catalog files in the flash recovery area: To catalog all files in the currently enabled flash recovery area without prompting the user for each one issue,



RMAN>CATALOG RECOVERY AREA NOPROMPT;

5)Catalog backup pieces: To catalog backup piece /oradata2/o4jccf4 issue,


RMAN>CATALOG BACKUPPIECE '/oradata2/o4jccf4';

Uncatalog Backup
In many cases you need to uncatalog command. Suppose you do not want a specific backup or copy to be eligible to be restored but also do not want to delete it.
To uncatalog all archived logs issue,


RMAN>CHANGE ARCHIVELOG ALL UNCATALOG;

To uncataog tablespace USERS issue,


RMAN>CHANGE BACKUP OF TABLESPACE USERS UNCATALOG;

To uncatalog a backuppiece name /oradata2/oft7qq issue,


RMAN>CHANGE BACKUPPIECE '/oradata2/oft7qq' UNCATALOG;

 
The catalog command allows you to enter new backup set–related information into the catalog. Any pre-existing catalog information that conflicts with the information being cataloged will be overwritten. This command can be useful 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

 

'/opt/oracle/oracle-10.0.0/dbs/backup';

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;

The catalog command allows you to catalog moved backup-set pieces. If you have moved a large number of backup-set pieces, then it can be a lot 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, which 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 in this fashion:

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 will try to catalog everything that matches the argument list, regardless of what type of file it is. 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.

 

The NOPROMPT clause supresses user confirmation for all matching files.

 Adarsh Kumar
DBA