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

Thursday, June 14, 2007

restore_controlfile_from_tape.ksh

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



#!/bin/ksh
. ~/.profile

##
## script name : restore_controlfile_from_tape.ksh
## Author : Ramakrishna Nemani
##
## Purpose :
## This script is for restoring the controlfile from tape (if you have lost all copies of control
## file). It assumes you have an rman backup (that was done with controlfile autobackup)
## availabale on tape
##
## Note :
## You have to replace DBID value with the DBID that you are attempting to restore the controlfile
## for. To execute this script You need login as a unix id that belongs to DBA group.
## You have to modify the tape or sbt settings to suit your environment
## 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_from_tape.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 SBT_TAPE TO '%F';
##
## Restore controlfile from autobackup first
##
RUN {
ALLOCATE CHANNEL tape_1 DEVICE TYPE sbt
PARMS 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)'
FORMAT '%u_%p_%c' ;
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