Wednesday, December 24, 2008

RMAN to Validate Before and After taking backup

If you want to verify whether there any physical or logical corruptions in database file before taking backup you can use the VALIDATE option of the BACKUP command.When performing a BACKUP... VALIDATE, RMAN reads the files to be backed up in their entirety, as it would during a real backup. It does not, however, actually produce any backup sets or image copies.If the backup validation discovers corrupt blocks, then RMAN updates the V$DATABASE_BLOCK_CORRUPTION view with rows describing the corruptions.Also with RMAN RESTORE ... VALIDATE before restore database or any datafile you can verify whether database can successfully restored or not.An example:--------------Before Performing Backup Check Any Physical or Logical Corruption:---------------------------------------------------------------------------------SQL> !rman target /Recovery Manager: Release 10.2.0.1.0 - Production on Wed Apr 23 17:15:24 2008Copyright (c) 1982, 2005, Oracle. All rights reserved.connected to target database: DATA1 (DBID=2547250380)RMAN> backup validate database;Starting backup at 23-APR-08using target database control file instead of recovery catalogallocated channel: ORA_DISK_1...including current control file in backupsetincluding current SPFILE in backupsetchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:02Finished backup at 23-APR-08After Backup Check if they can be Restored Successfully-------------------------------------------------------------Using Validate BackupSet--------------------------RMAN> validate backupset 4;using channel ORA_DISK_1channel ORA_DISK_1: starting validation of datafile backupsetchannel ORA_DISK_1: reading from backup piece /oracle/app/oracle/product/10.2.0/db_1/dbs/05jei8qh_1_1channel ORA_DISK_1: restored backup piece 1piece handle=/oracle/app/oracle/product/10.2.0/db_1/dbs/05jei8qh_1_1 tag=TAG20080423T165857channel ORA_DISK_1: validation complete, elapsed time: 00:00:25Using RESTORE .. VALIDATE----------------------------RMAN> restore database validate;Starting restore at 23-APR-08using channel ORA_DISK_1channel ORA_DISK_1: starting validation of datafile backupsetchannel ORA_DISK_1: reading from backup piece /oracle/app/oracle/product/10.2.0/db_1/dbs/0bjeiams_1_1channel ORA_DISK_1: restored backup piece 1piece handle=/oracle/app/oracle/product/10.2.0/db_1/dbs/0bjeiams_1_1 tag=TAG20080423T173108channel ORA_DISK_1: validation complete, elapsed time: 00:00:04Finished restore at 23-APR-08You can also validate single tablespace or datafile or any other like,RMAN> restore datafile 1 validate;RMAN> restore tablespace system validate;RMAN> restore controlfile validate;RMAN> restore spfile validate;

No comments:

Post a Comment