{"id":147,"date":"2012-03-18T18:18:59","date_gmt":"2012-03-18T16:18:59","guid":{"rendered":"http:\/\/www.ludovicocaldara.net\/dba\/?p=147"},"modified":"2013-11-11T11:07:53","modified_gmt":"2013-11-11T09:07:53","slug":"script-that-duplicate-a-database-using-a-physical-standby-rac-as-source","status":"publish","type":"post","link":"https:\/\/www.ludovicocaldara.net\/dba\/script-that-duplicate-a-database-using-a-physical-standby-rac-as-source\/","title":{"rendered":"Script that duplicates a database using a physical standby RAC  as source"},"content":{"rendered":"<p><a href=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2012\/03\/RACDGDUPLICATE1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-149 alignleft\" title=\"RACDGDUPLICATE\" src=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2012\/03\/RACDGDUPLICATE1-300x110.png\" alt=\"\" width=\"300\" height=\"110\" srcset=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2012\/03\/RACDGDUPLICATE1-300x110.png 300w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2012\/03\/RACDGDUPLICATE1-500x184.png 500w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2012\/03\/RACDGDUPLICATE1.png 664w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>\u00a0It&#8217;s possibile to duplicate a database for testing purposes (it&#8217;s an example) using a standby database as source. This allows you to off-load the production environment.<\/p>\n<p>This is a simple script that makes use of ASM and classic duplicate, although I guess it&#8217;s possible to use the standby DB for a duplicate from active database.<br \/>\nYou can launch it everyday to align your test env at a point in time.<\/p>\n<pre lang=\"bash\">\r\n#!\/bin\/bash\r\nif [ $USER != 'oracle' ] ; then\r\n        echo \"need to be oracle\"\r\n        exit 0\r\nfi\r\n\r\n. $HOME\/set11\r\nexport ORACLE_SID=test1\r\n\r\nsrvctl stop database -d test -o immediate\r\n\r\n## this is supposed to be a script that erase your ASM  from your old test dbfiles:\r\n## it's as simple as running with the CORRECT ENV:\r\n## asmcmd rm -rf \\\r\n##   +DATA\/TEST\/ONLINELOG\r\n##   +DATA\/TEST\/DATAFILE\r\n##   +DATA\/TEST\/CONTROLFILE\r\n##   +DATA\/TEST\/TEMPFILE\r\n##   +FRA\/TEST\/ONLINELOG\r\n##   +FRA\/TEST\/CONTROLFILE\r\n\r\nssh grid@testsrv \/shared\/refresh_test\/remove_test_files.sh\r\n\r\nsqlplus \/ as sysdba < <EOF\r\n        set echo on\r\n        startup nomount\r\n        alter system set cluster_database=false scope=spfile;\r\n        shutdown immediate\r\n        startup nomount\r\nEOF\r\n\r\nrman <<EOF\r\nconnect target sys\/mystrongpassword@stdby\r\nconnect auxiliary \/\r\n\r\nduplicate database to 'test' until time \"trunc(sysdate)+6\/24\";\r\n\r\nEOF\r\n\r\n\r\nsqlplus \/ as sysdba <<EOF\r\n        set echo on\r\n        alter system set cluster_database=true scope=spfile;\r\n        shutdown immediate\r\n        startup mount\r\n        alter database noarchivelog;\r\n        shutdown immediate\r\nEOF\r\n\r\n\r\nsrvctl start database -d test\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0It&#8217;s possibile to duplicate a database for testing purposes (it&#8217;s an example) using a standby database as source. This allows you to off-load the production environment. This is a simple script that makes use of ASM and classic duplicate, although &hellip; <a href=\"https:\/\/www.ludovicocaldara.net\/dba\/script-that-duplicate-a-database-using-a-physical-standby-rac-as-source\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[132,1],"tags":[40,45,9,22,29,23,44,31],"class_list":["post-147","post","type-post","status-publish","format-standard","hentry","category-triblog","category-uncategorized","tag-asm","tag-duplicate","tag-oracle","tag-oracle-database","tag-oracle-dataguard","tag-rac","tag-rman","tag-standby"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/comments?post=147"}],"version-history":[{"count":6,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":156,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/147\/revisions\/156"}],"wp:attachment":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/media?parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/categories?post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/tags?post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}