Simple Bash Script to automate restore backup of controlfile.
Came up with this very simple script to automate the restore of control file from given backup.
This was to answer a question posted on OTN,
https://community.oracle.com/message/13668456#13668456
Can pass the backup date (bdate), or any other parameter in order to isolate a particular backup piece from bash using above script.
This was to answer a question posted on OTN,
https://community.oracle.com/message/13668456#13668456
[oracle@prima ~]$ cat cnt_rst.sh
export ORACLE_HOME=/orahome/product/11.2.0/dbhome_1
export ORACLE_SID=DG1
bdate=20151214
rman target / cmdfile='to_os.scr' log='os_file.txt'
#bpc=`cat os_file.txt | grep -i $bdate | grep -i ncnn | cut -d '/' -f 2-` - to restore from piece
bpc=`cat os_file.txt | grep -i 20151214 | grep -i tag: | awk '{print $NF}'`
echo "run {" >> rst_cnt.scr
#echo "restore controlfile to '/home/oracle/cnt_$bdate.cnt' from '/$bpc';" >> rst_cnt.scr - to restore from piece
echo "restore controlfile to '/home/oracle/cnt_$bdate.cnt' from tag $bpc;" >> rst_cnt.scr
echo "}" >> rst_cnt.scr
rman target / cmdfile='rst_cnt.scr' log='rst_cnt.log'
rm -rf rst_cnt.scr os_file.txt
[oracle@prima ~]$ cat to_os.scr
list backup of controlfile;
[oracle@prima ~]$
Can pass the backup date (bdate), or any other parameter in order to isolate a particular backup piece from bash using above script.
Comments
Post a Comment