Oracle Rman Restore Validate Backup Sets

RMAN Validate Backup
http://gavinsoorma.com/2009/07/rman-validate-database-backups/

The validate command for backup and restore is useful to confirm that backup and restoration is posssible and valid without actually backing up or restoring datafiles.

We can validate the restore of a spfile,controlfile,archivelog or even the whole database backup.

The following example enables us to specify a point in time upto which we need to test the validity of a backup.

RMAN> run {
2> set until time “to_date(’23-JUL-2009 17:00:00′,’DD-MON-YYYY HH24:MI:SS’)”;
3> restore database validate;4> }

executing command: SET until clause
using target database control file instead of recovery catalog

Starting restore at 23-JUL-09
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=159 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: Data Protection for Oracle: version 5.5.1.0
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=143 devtype=DISK

channel ORA_SBT_TAPE_1: starting validation of datafile backupset
channel ORA_SBT_TAPE_1: reading from backup piece 1pkkbkop_1_1
channel ORA_SBT_TAPE_1: restored backup piece 1
piece handle=1pkkbkop_1_1 tag=TAG20090717T085801
channel ORA_SBT_TAPE_1: validation complete, elapsed time: 00:04:27
Finished restore at 23-JUL-09

We can validate spfile and controlfile backups as well as shown below

RMAN> restore validate spfile;
Starting restore at 23-JUL-09
using channel ORA_SBT_TAPE_1
using channel ORA_DISK_1

channel ORA_DISK_1: starting validation of datafile backupset
channel ORA_DISK_1: reading from backup piece /u02/oradata/testdb/TESTDB/autobackup/2009_07_22/o1_mf_s_692887841_56f6o2jr_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u02/oradata/testdb/TESTDB/autobackup/2009_07_22/o1_mf_s_692887841_56f6o2jr_.bkp tag=TAG20090722T125041
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
Finished restore at 23-JUL-09

RMAN> restore validate controlfile;

Starting restore at 23-JUL-09
using channel ORA_SBT_TAPE_1
using channel ORA_DISK_1

channel ORA_DISK_1: starting validation of datafile backupset
channel ORA_DISK_1: reading from backup piece /u02/oradata/testdb/TESTDB/autobackup/2009_07_22/o1_mf_s_692887841_56f6o2jr_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u02/oradata/testdb/TESTDB/autobackup/2009_07_22/o1_mf_s_692887841_56f6o2jr_.bkp tag=TAG20090722T125041
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
Finished restore at 23-JUL-09

Let us now simulate a case where the restore validate will fail because either a backup or backupset is not available or because a file is not available on the disk itself.

We will rename one of the most recent archivelog files and then attempt a restore validate of archivellogs for the past day.

$ mv arch.355.1.692887607.log arch.355.1.692887607.log.old

RMAN> restore validate archivelog from time ‘sysdate -1′;

Starting restore at 23-JUL-09
using target database control file instead of recovery catalog
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=140 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: Data Protection for Oracle: version 5.5.1.0
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/23/2009 21:22:21
RMAN-06026: some targets not found – aborting restore
RMAN-06025: no backup of log thread 1 seq 355 lowscn 5192098 found to

This command can be safely run at anytime .

Also worth noting that even if you simply forget to enter validate and type for example -

RMAN > restore database ;

RMAN will never restore on top of an ‘OPEN’ database -

An error similar to the one below will be received if you try to overwrite files of an open database.

ORA-19870: error while restoring backup piece 16kermqo_1_1
ORA-19573: cannot obtain exclusive enqueue for datafile 2