Wednesday, April 30, 2008

Use of Tag in Backup and Recovery

A tag is a symbolic name for a backup set or image copy. While creating backup you can assign a user-specified character string called a tag to backup sets and image copies and later using this tag name you can restore the backup set or image copy.

•The maximum length of a tag is 30 bytes.

•If you don't assign any tag then RMAN itself assigns tag to a backupset or image copy in the format of TAGYYYYMMDDTHHMMSS, where
YYYY is the year,
MM is the month,
DD is the day,
HH is the hour (in 24-hour format),
MM is theminutes, and
SS is the seconds.

•If multiple backup sets are created by one BACKUP command, then each backup piece is assigned the
same default tag.

•If controlfile autobackup is on then tag is not assigned only that backup piece.

•To use of tag you can simply use TAG tag_name. Like,

RMAN> backup spfile tag test_sp;
RMAN> backup datafile 4 tag test_backup;


•Tags do not need to be unique, so multiple backup sets or image copies can have the same tag. Now if I recall restore command with tag name then most recent intended assigned tag is invoked.

•Here is an example how we can use TAG in restore command.

RMAN> list backup by file;

List of Datafile Backups
========================

File Key TY LV S Ckp SCN Ckp Time #Pieces #Copies Compressed Tag
---- ------- - -- - ---------- --------- ------- ------- ---------- ---
4 61 B F A 953430 30-APR-08 1 1 NO TEST_BACKUP
.
.
.


RMAN> sql'alter database datafile 4 offline';


sql statement: alter database datafile 4 offline

RMAN> restore datafile 4 from tag TEST_BACKUP;


Starting restore at 30-APR-08
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /oradata2/data1/data1/users01.dbf
channel ORA_DISK_1: reading from backup piece /oradata2/flash_recovery_area/DATA1/backupset/2008_04_30/o1_mf_nnndf_TEST_BACKUP_41km20xo_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/oradata2/flash_recovery_area/DATA1/backupset/2008_04_30/
o1_mf_nnndf_TEST_BACKUP_41km20xo_.bkp tag=TEST_BACKUP
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 30-APR-08

No comments:

Post a Comment