Wednesday, July 15, 2015

Testing RMAN Restore

Starting 10g, we can test our backups whether backups are valid and can be used for a successful restore/recovery of the database or not. We can do so by using “RESTORE VALIDATE” command from RMAN. RESTORE VALIDATE command would simulate a restore of the backups by reading backup pieces. If it completes successfully, it would mean that backup is good and can be used for restoration and recovery of database in case of media failure or a disaster.

This can be used on the production server itself where backup was taken, but it is better not to test in on production. In the following example I will show you how to perform this. First I am taking a backup on my database on windows platform and then validating the backup.

Taking backup of the database

RMAN> backup format 'c:\dbbackup\DB_BACKUP_%U.bak' database plus archivelog delete input;

Starting backup at 10-JUL-15
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=45 RECID=9 STAMP=884684979
input archived log thread=1 sequence=46 RECID=10 STAMP=884684980
input archived log thread=1 sequence=47 RECID=11 STAMP=884684984
input archived log thread=1 sequence=48 RECID=12 STAMP=884684984
input archived log thread=1 sequence=49 RECID=13 STAMP=884684984
input archived log thread=1 sequence=50 RECID=14 STAMP=884684997
channel ORA_DISK_1: starting piece 1 at 10-JUL-15
channel ORA_DISK_1: finished piece 1 at 10-JUL-15
piece handle=C:\DBBACKUP\DB_BACKUP_0BQBME66_1_1.BAK tag=TAG20150710T094957 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=C:\APP\SALMQURE\PRODUCT\12.1.0\DBHOME_1\RDBMS\ARC0000000045_0870715164.0001 RECID=9 STAMP=884684979
archived log file name=C:\APP\SALMQURE\PRODUCT\12.1.0\DBHOME_1\RDBMS\ARC0000000046_0870715164.0001 RECID=10 STAMP=884684980
archived log file name=C:\APP\SALMQURE\PRODUCT\12.1.0\DBHOME_1\RDBMS\ARC0000000047_0870715164.0001 RECID=11 STAMP=884684984
archived log file name=C:\APP\SALMQURE\PRODUCT\12.1.0\DBHOME_1\RDBMS\ARC0000000048_0870715164.0001 RECID=12 STAMP=884684984
archived log file name=C:\APP\SALMQURE\PRODUCT\12.1.0\DBHOME_1\RDBMS\ARC0000000049_0870715164.0001 RECID=13 STAMP=884684984
archived log file name=C:\APP\SALMQURE\PRODUCT\12.1.0\DBHOME_1\RDBMS\ARC0000000050_0870715164.0001 RECID=14 STAMP=884684997
Finished backup at 10-JUL-15

Starting backup at 10-JUL-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=C:\APP\SALMQURE\ORADATA\SALMAN12\SYSTEM01.DBF
input datafile file number=00003 name=C:\APP\SALMQURE\ORADATA\SALMAN12\SYSAUX01.DBF
input datafile file number=00005 name=C:\APP\SALMQURE\ORADATA\SALMAN12\UNDOTBS01.DBF
input datafile file number=00006 name=C:\APP\SALMQURE\ORADATA\SALMAN12\USERS01.DBF
input datafile file number=00010 name=C:\APP\SALMQURE\ORADATA\SALMAN12\TEST01.DBF
channel ORA_DISK_1: starting piece 1 at 10-JUL-15
channel ORA_DISK_1: finished piece 1 at 10-JUL-15
piece handle=C:\DBBACKUP\DB_BACKUP_0CQBME67_1_1.BAK tag=TAG20150710T094959 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00015 name=C:\APP\SALMQURE\ORADATA\SALMAN12\PDB1\SYSAUX01.DBF
input datafile file number=00014 name=C:\APP\SALMQURE\ORADATA\SALMAN12\PDB1\SYSTEM01.DBF
input datafile file number=00016 name=C:\APP\SALMQURE\ORADATA\SALMAN12\PDB1\PDB1_USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 10-JUL-15
channel ORA_DISK_1: finished piece 1 at 10-JUL-15
piece handle=C:\DBBACKUP\DB_BACKUP_0DQBME7B_1_1.BAK tag=TAG20150710T094959 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00025 name=C:\APP\SALMQURE\ORADATA\SALMAN12\PDB2\SYSAUX01.DBF
input datafile file number=00024 name=C:\APP\SALMQURE\ORADATA\SALMAN12\PDB2\SYSTEM01.DBF
channel ORA_DISK_1: starting piece 1 at 10-JUL-15
channel ORA_DISK_1: finished piece 1 at 10-JUL-15
piece handle=C:\DBBACKUP\DB_BACKUP_0EQBME84_1_1.BAK tag=TAG20150710T094959 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=C:\APP\SALMQURE\ORADATA\SALMAN12\PDBSEED\SYSAUX01.DBF
input datafile file number=00002 name=C:\APP\SALMQURE\ORADATA\SALMAN12\PDBSEED\SYSTEM01.DBF
channel ORA_DISK_1: starting piece 1 at 10-JUL-15
channel ORA_DISK_1: finished piece 1 at 10-JUL-15
piece handle=C:\DBBACKUP\DB_BACKUP_0FQBME8J_1_1.BAK tag=TAG20150710T094959 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 10-JUL-15

Starting backup at 10-JUL-15
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=51 RECID=15 STAMP=884685091
channel ORA_DISK_1: starting piece 1 at 10-JUL-15
channel ORA_DISK_1: finished piece 1 at 10-JUL-15
piece handle=C:\DBBACKUP\DB_BACKUP_0GQBME93_1_1.BAK tag=TAG20150710T095131 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=C:\APP\SALMQURE\PRODUCT\12.1.0\DBHOME_1\RDBMS\ARC0000000051_0870715164.0001 RECID=15 STAMP=884685091
Finished backup at 10-JUL-15

Starting Control File and SPFILE Autobackup at 10-JUL-15
piece handle=C:\APP\SALMQURE\PRODUCT\12.1.0\DBHOME_1\DATABASE\C-3945497372-20150710-01 comment=NONE
Finished Control File and SPFILE Autobackup at 10-JUL-15

Performing RESTORE VALIDATE
For archivelog files restore validation, I am providing start log sequence number which is part of the backup and needed for the recovery using this backup.
RMAN> restore database validate;

Starting restore at 10-JUL-15
using channel ORA_DISK_1

channel ORA_DISK_1: starting validation of datafile backup set
channel ORA_DISK_1: reading from backup piece C:\DBBACKUP\DB_BACKUP_0CQBME67_1_1.BAK
channel ORA_DISK_1: piece handle=C:\DBBACKUP\DB_BACKUP_0CQBME67_1_1.BAK tag=TAG20150710T094959
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting validation of datafile backup set
channel ORA_DISK_1: reading from backup piece C:\DBBACKUP\DB_BACKUP_0DQBME7B_1_1.BAK
channel ORA_DISK_1: piece handle=C:\DBBACKUP\DB_BACKUP_0DQBME7B_1_1.BAK tag=TAG20150710T094959
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting validation of datafile backup set
channel ORA_DISK_1: reading from backup piece C:\DBBACKUP\DB_BACKUP_0EQBME84_1_1.BAK
channel ORA_DISK_1: piece handle=C:\DBBACKUP\DB_BACKUP_0EQBME84_1_1.BAK tag=TAG20150710T094959
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting validation of datafile backup set
channel ORA_DISK_1: reading from backup piece C:\DBBACKUP\DB_BACKUP_0FQBME8J_1_1.BAK
channel ORA_DISK_1: piece handle=C:\DBBACKUP\DB_BACKUP_0FQBME8J_1_1.BAK tag=TAG20150710T094959
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:00:07
Finished restore at 10-JUL-15

RMAN> restore archivelog from logseq 45 validate;

Starting restore at 10-JUL-15
using channel ORA_DISK_1

channel ORA_DISK_1: starting validation of archived log backup set
channel ORA_DISK_1: reading from backup piece C:\DBBACKUP\DB_BACKUP_0BQBME66_1_1.BAK
channel ORA_DISK_1: piece handle=C:\DBBACKUP\DB_BACKUP_0BQBME66_1_1.BAK tag=TAG20150710T094957
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting validation of archived log backup set
channel ORA_DISK_1: reading from backup piece C:\DBBACKUP\DB_BACKUP_0GQBME93_1_1.BAK
channel ORA_DISK_1: piece handle=C:\DBBACKUP\DB_BACKUP_0GQBME93_1_1.BAK tag=TAG20150710T095131
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
Finished restore at 10-JUL-15

No comments:

Popular Posts - All Times