Oracle Restore Control File Script – Linux Cut Command – RMAN Restore Script

Hi

I wanted share one useful script which I wrote few minutes ago ( part of my big project )  🙂

You know we do Oracle Restore and we need few things. One of the most important thing is to restore  control file.

You need to find it

Write name into the restore command

Start restore

Repeat it for every restore ( ıt was kind boring for me 🙂  )

 

Thats why I wrote this

ssh <hostnameoftheproduction> ‘export lastlog=$(find /u01/app/oracle/diag/rdbms/exaprod/PROD1/trace/rman_PROD_ARCH_* -type f | xargs grep -l “c-” | xargs ls -rt | tail -n 1) ; grep “c-” $lastlog | cut -f2 -d’=’ |cut -f1 -d” “‘ > /tmp/controlfile

export controlfile=$(cat /tmp/controlfile)

echo $controlfile

 

You Need to change ;

RMAN Backup Log= /u01/app/oracle/diag/rdbms/exaprod/PROD1/trace/rman_PROD_*2019*

hostnameoftheproduction

 

Now we know control file and we have variable, lets make this command more useful with the below script

 

echo “” > restore.rman
echo “set dbid=18578182” >> restore.rman
echo “run {” >> restore.rman
echo “ALLOCATE CHANNEL chtape1 TYPE ‘SBT_TAPE’ PARMS=’SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so64′;” >> restore.rman
echo “SEND ‘NB_ORA_CLIENT=tristexadbadm01,NB_ORA_POLICY=tristexadbadm01_rman_PROD,NB_ORA_SERV=tristbckp’;” >> restore.rman
echo “restore controlfile from ‘$controlfile’;” >> restore.rman
echo “alter database mount;” >> restore.rman
echo “SQL “alter database flashback off”;” >> restore.rman
echo “}” >> restore.rman

rman TARGET / CATALOG rman/<password>@CATDB
@restore.rman

 

You Need to change ;

hostnames and backup server name in the restore.rman script

 

This script is usefull for DBAs who has to do restore too much… Told be truth you have to improve this script more to do whole restore database which I am working on it 🙂

 

I hope you like it. Please don’t hesitate to ask any script you want.

 

 

Cihan Gedik

I am currently working as Senior Oracle Application Database Administrator. I have experienced many EBS database upgrade, migrations, Fresh EBS installations, Solaris to Linux, Windows to Linux replatform migration projects in medium and large companies and also experienced core database migration projects for one of the biggest bank of Katar. With my colleagues we decided to run this platform to share our knowledge