RMAN Validating Backups and Recovery
To check the datafiles for any physical or logical corruption
and verify whether a datafile is in the correct directory, use the
backup validate command. This command does not create a backup of
any datafile; it checks for validity of the datafiles and updates
the v$database_block_corruption view in case it finds any
corruption. After getting the list of corrupted data blocks, use
the Block Media Recovery feature of RMAN to recover the corrupted
blocks. This feature is explained in more detail in Chapter 4.
It should be mentioned that by default, RMAN checks for
physical corruption. By using check logical syntax, we can check
for logical corruptionas
well. Here, we provide an example of checking and validating a
datafile by first manually corrupting it.
To begin, create a tablespace and table by assigning it to that
tablespace. Then insert data in the table as follows:
SQL>
create
tablespace tbs_test datafile 'c:\tbs_test.dbf' size 1m;
Tablespace created.
SQL>
create
table tbl_test (name varchar2(20)) tablespace tbs_test;
Table created.
SQL>
insert into
tbl_test values('oracle');
1 row created.
SQL>
commit;
Commit complete.
Then query the v$database_block_corruption view. As we have
not validated the datafile, it must be empty:
SQL>
select * from
v$database_block_corruption;
no rows selected
Bring the tablespace to the offline mode, and then corrupt the
datafile using the manual corruption methods that is described in
Chapter 4. Then bring the tablespace to the online mode and query
the table. The following error will occur:
SQL>
alter
tablespace tbs_test offline;
Tablespace altered.
SQL>
alter
tablespace tbs_test online;
Tablespace altered.
SQL>
select * from
tbl_test;
select * from
tbl_test
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 8, block # 13)
ORA-01110: data file 8: 'C:\tbs_test.dbf'
Now use the backup validate command
to check that datafile for any corruption. Then query the
v$database_block_recovery view:
RMAN> backup validate tablespace
tbs_test;
SQL>
select * from
v$database_block_corruption;
FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTION
---------- ---------- ---------- ------------------ ---------
8 13 1 0 CHECKSUM
SQL>
This shows that datafile number 8 has a block corruption in
block number 13. Only one block has been corrupted. This
information will help us to recover that block using Block Media
Recovery.
To validate the tablespace, use the following command:
RMAN> backup
validate tablespace tbs_test;
To validate a specific datafile, use the following command:
RMAN> backup
validate datafile 8;
To check the whole database, use the following command:
RMAN> backup
validate database;
To check all archived redo log files, use the following
command:
RMAN> backup
validate archivelog all;
To check the spfile, use the following command:
RMAN> backup
validate spfile;
To check the current control file, use the following command:
RMAN> backup
validate current control file;
Just as a datafile can be validated for a backup operation, a
backup of a datafile can be validated for a restore. To check if
a backup is valid and available for a restore operation, use the
restore ?. validate command.
To check backup of the control file, use the following command:
RMAN> restore
control file validate;
To check backup of the spfile,
use the following command:
RMAN> restore
spfile validate;
To check backup of tablespace users, use the following command:
RMAN> restore
tablespace users validate;
To check backup of a datafile,
use the following command:
RMAN> restore
datafile 4 validate;
To check backup of all archived redo log files,
use the following command:
RMAN> restore
archivelog all validate;
To check backup of the whole database, use the following
command:
RMAN> restore
database validate;
If RMAN is unable to find the backup file, it returns an error
as follows:
RMAN> restore spfile validate;
Starting restore at 22-AUG-09
using channel ORA_DISK_1
.......................Output omitted
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified
failover to previous backup
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-03002: failure of restore command at 08/22/2009 19:49:51
RMAN-06026: some targets not found - aborting restore
RMAN-06729: no backup of the SPFILE found to restore
RMAN>
In 10g, it is possible to check only backup sets for any
corruptions by using the validate backupset - command. To check a
backup set, use:
RMAN> validate
backupset 2;
In Oracle 11g, the validate command was expanded with new
features. The syntax of the new validate commandis the same as the syntax of the backup validate
command. With the new validate command, almost everything that
needs to be checked can be done. For example, to check validity
of the backup of the spfile, use the following command:
Moreover, parallelizing the validity
process can be done by dividing it into specified section sizes
using the section size command. It should be used when different
channels have been allocated and the validity needs to be spread
over those channels. In the following scenario, we open three
different channels and parallelize the validity over these three
channels with 300M per channel:
RMAN>
run
{
allocate channel c1 devide type disk;
allocate channel c2 devide type disk;
allocate channel c3 devide type disk;
validate database section size 300m;
}