{"id":11443,"date":"2019-10-05T22:15:53","date_gmt":"2019-10-05T22:15:53","guid":{"rendered":"https:\/\/ittutorial.org\/?p=11443"},"modified":"2019-11-27T11:48:47","modified_gmt":"2019-11-27T11:48:47","slug":"oracle-restore-control-file-script-linux-cut-command-rman-restore-script","status":"publish","type":"post","link":"https:\/\/ittutorial.org\/oracle-restore-control-file-script-linux-cut-command-rman-restore-script\/","title":{"rendered":"Oracle Restore Control File Script &#8211; Linux Cut Command &#8211; RMAN Restore Script"},"content":{"rendered":"<p>Hi<\/p>\n<p>I wanted share one useful script which I wrote few minutes ago ( part of my big project )\u00a0 \ud83d\ude42<\/p>\n<p>You know we do Oracle Restore and we need few things. One of the most important thing is to restore\u00a0 control file.<\/p>\n<p>You need to find it<\/p>\n<p>Write name into the restore command<\/p>\n<p>Start restore<\/p>\n<p>Repeat it for every restore ( \u0131t was kind boring for me \ud83d\ude42\u00a0 )<\/p>\n<p>&nbsp;<\/p>\n<p>Thats why I wrote this<\/p>\n<p>ssh &lt;hostnameoftheproduction&gt; &#8216;export lastlog=$(find \/u01\/app\/oracle\/diag\/rdbms\/exaprod\/PROD1\/trace\/rman_PROD_ARCH_* -type f | xargs grep -l &#8220;c-&#8221; | xargs ls -rt | tail -n 1) ; grep &#8220;c-&#8221; $lastlog | cut -f2 -d&#8217;=&#8217; |cut -f1 -d&#8221; &#8220;&#8216; &gt; \/tmp\/controlfile<\/p>\n<p>export controlfile=$(cat \/tmp\/controlfile)<\/p>\n<p>echo $controlfile<\/p>\n<p>&nbsp;<\/p>\n<p>You Need to change ;<\/p>\n<p>RMAN Backup Log= \/u01\/app\/oracle\/diag\/rdbms\/exaprod\/PROD1\/trace\/rman_PROD_*2019*<\/p>\n<p>hostnameoftheproduction<\/p>\n<p>&nbsp;<\/p>\n<p>Now we know control file and we have variable, lets make this command more useful with the below script<\/p>\n<p>&nbsp;<\/p>\n<p>echo &#8220;&#8221; &gt; restore.rman<br \/>\necho &#8220;set dbid=18578182&#8221; &gt;&gt; restore.rman<br \/>\necho &#8220;run {&#8221; &gt;&gt; restore.rman<br \/>\necho &#8220;ALLOCATE CHANNEL chtape1 TYPE &#8216;SBT_TAPE&#8217; PARMS=&#8217;SBT_LIBRARY=\/usr\/openv\/netbackup\/bin\/libobk.so64&#8242;;&#8221; &gt;&gt; restore.rman<br \/>\necho &#8220;SEND &#8216;NB_ORA_CLIENT=tristexadbadm01,NB_ORA_POLICY=tristexadbadm01_rman_PROD,NB_ORA_SERV=tristbckp&#8217;;&#8221; &gt;&gt; restore.rman<br \/>\necho &#8220;restore controlfile from &#8216;$controlfile&#8217;;&#8221; &gt;&gt; restore.rman<br \/>\necho &#8220;alter database mount;&#8221; &gt;&gt; restore.rman<br \/>\necho &#8220;SQL &#8220;alter database flashback off&#8221;;&#8221; &gt;&gt; restore.rman<br \/>\necho &#8220;}&#8221; &gt;&gt; restore.rman<\/p>\n<p>rman TARGET \/ CATALOG rman\/&lt;password&gt;@CATDB<br \/>\n@restore.rman<\/p>\n<p>&nbsp;<\/p>\n<p>You Need to change ;<\/p>\n<p>hostnames and backup server name in the restore.rman script<\/p>\n<p>&nbsp;<\/p>\n<p>This script is usefull for DBAs who has to do restore too much&#8230; Told be truth you have to improve this script more to do whole restore database which I am working on it \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n<p>I hope you like it. Please don&#8217;t hesitate to ask any script you want.<\/p>\n<p>&nbsp;<\/p>\n<h4><span style=\"color: #ff0000;\">Do you want to learn Oracle Database for Beginners, then read the following articles.<\/span><\/h4>\n<p>https:\/\/ittutorial.org\/oracle-database-19c-tutorials-for-beginners\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi I wanted share one useful script which I wrote few minutes ago ( part of my big project )\u00a0 \ud83d\ude42 You know we do Oracle Restore and we need few things. One of the most important thing is to restore\u00a0 control file. You need to find it Write name into the restore command Start &hellip;<\/p>\n","protected":false},"author":32,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11,1994,5042],"tags":[6433,6428,2028,425,959,1120,1327,6427,6429,1478,6431,6430,1551,6432],"class_list":["post-11443","post","type-post","status-publish","format-standard","","category-linux","category-oracle","category-rman","tag-bash","tag-control","tag-control-file","tag-controlfile","tag-linux","tag-oracle","tag-oracle-rman","tag-restore","tag-restore-control-file","tag-rman","tag-rman-restore","tag-script","tag-shell","tag-shell-script"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/11443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/comments?post=11443"}],"version-history":[{"count":7,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/11443\/revisions"}],"predecessor-version":[{"id":12847,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/11443\/revisions\/12847"}],"wp:attachment":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media?parent=11443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/categories?post=11443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/tags?post=11443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}