Today's Birthday
Quote of the Day
This Day in History

Thursday, June 14, 2007

restore_controlfile.ksh

If you have lost all copies of the controlfile then use this script to restore the controlfile from rman disk backup


#!/bin/ksh
. ~/.profile

##
## script name : restore_controlfile.ksh
## Author : Ramakrishna Nemani
##
## Purpose :
## This script is for restoring the controlfile from disk (if you have lost all copies of
## the controlfile). It assumes you have an rman backup (that was done with controlfile
## autobackup option)
##
## Note :
## You have to replace DBID value with the DBID that you are attempting to restore the spfile
## for. To execute this script You need login as a unix id that belongs to DBA group.
## Make sure you have configured the rman automatic channels etc..
## I have tested this script on UNIX/LINUX platform using Oracle 10g. Use it at your own risk.
##
## This is an example or sample script
##

export ORACLE_SID=slsd

rman << EOF > ./rstr_controlfile.log

CONNECT TARGET /

STARTUP NOMOUNT;

##
## set dbid because we are not using an rman catalog
##
SET DBID 3183102432 ;

##
## Specify AUTOBACKUP Format
##
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'controlfile_%F' ;
##
## Restore controlfile from autobackup
##
RUN {
ALLOCATE CHANNEL disk_1 DEVICE TYPE disk ;
RESTORE CONTROLFILE FROM AUTOBACKUP ;
}
##
## Mount the database with newly restored controlfile
##
alter database mount ;
##
## Issue a "recover database ;" command to make sure that we don't run into
## any "ORA-01152: file 1 was not restored from a sufficiently old backup"
## kind of errors.
## Open the database with "alter database open resetlogs ;"
##
recover database ;
alter database open resetlogs ;
##
## Make sure that you do a complete database backup after opening
## the database with resetlogs option
##

EOF

No comments:

Post a Comment