Friday, October 08, 2010

Recover from Consistent Backup

Scenario  : One of more datafiles are lost of a nonarchive database
Action    :  Recover the database from consistent backup


1-2-3-4 step for  recover database

Step 1

Get the dbid from last backup log file, look for structure like this
 “c--YYYYMMDD-SS”

Eg. 'c-4205377152-20040130-00

Step 2

Create command file for recovering the database

rman_restore_db.cmd
# get dbid value from last backup log
set dbid=2369188274;
startup nomount;
RUN
{
  SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO    '/orabkup1/oracle/BACKUP/testdb/ora_cf_%F';

  RESTORE CONTROLFILE FROM AUTOBACKUP MAXDAYS 360 ;
# restore controlfile from 'c-4205377152-20040130-00';

  ALTER DATABASE MOUNT;
  RESTORE DATABASE ;
  RECOVER DATABASE NOREDO;
  ALTER DATABASE OPEN RESETLOGS;
  #
  # NOTE: You MUST take another COLD/HOT  backup in order to recover this  instances again
  # The open resetlogs invalidated all prior backups.
  #
}

Step 3

This step is to user rman to execute the command file  created at step 2

rman_restore_db.sh
. ~/.profile
ORACLE_SID=testdb;ORAENV_ASK=NO;. oraenv;ORAENV_ASK=YES
cd /ora01/oracle/admin/BACKUP/testdb
rman nocatalog target / cmdfile rman_restore_db.cmd
status=$?
exit $status

step 4

create this script to actually run the restore, now. This step creates the logfile of rman restore of database.

restore.sh
echo "rman_restore_db > rman_restore_db.log 2>&1" | at now

Hope this help. Regards Rupam