{"id":3650,"date":"2020-11-22T18:27:22","date_gmt":"2020-11-22T18:27:22","guid":{"rendered":"https:\/\/nenadnoveljic.com\/blog\/?p=3650"},"modified":"2020-11-22T18:28:32","modified_gmt":"2020-11-22T18:28:32","slug":"duplicating-pluggable-databases-with-sysbackup","status":"publish","type":"post","link":"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/","title":{"rendered":"Duplicating Pluggable Databases with sysbackup"},"content":{"rendered":"<p>According to <a href=\"https:\/\/docs.oracle.com\/en\/database\/oracle\/oracle-database\/19\/bradv\/rman-duplicating-databases.html#GUID-9E630E2C-3D1B-4594-B738-4B5B43E50C58\">Backup and Recovery User&#8217;s Guide<\/a>, duplicating of a pluggable database in the existing CDB should work with both sysdba and sysbackup privileges:<br \/>\n&#8220;Connect AS TARGET to the root of the source CDB as a common user with the SYSDBA or SYSBACKUP privilege.<br \/>\nConnect AS AUXILIARY to the root of the destination CDB as a common user with the SYSDBA or SYSBACKUP privilege&#8221;.<br \/>\nsysbackup is more secure because of the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Principle_of_least_privilege\">principle of least privilege<\/a>.<br \/>\nBut duplicate fails with sysbackup, because of &#8220;insufficient privileges&#8221;:<\/p>\n<pre><code>connect target 'sysbackup\/password@SRCCDB as sysbackup'\nconnect auxiliary 'sysbackup\/password@DESTCDB as sysbackup'\nduplicate pluggable database SRCPDB as DESTPDB to DESTCDB from active database;\n\n...\nStarting Duplicate PDB at 20-NOV-20\nusing target database control file instead of recovery catalog\nallocated channel: ORA_AUX_DISK_1\nchannel ORA_AUX_DISK_1: SID=226 device type=DISK\ncurrent log archived\nduplicating Online logs to Oracle Managed File (OMF) location\nduplicating Datafiles to Oracle Managed File (OMF) location\nRMAN-00571: ===========================================================\nRMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============\nRMAN-00571: ===========================================================\nRMAN-03002: failure of Duplicate PDB command at 11\/20\/2020 15:20:29\nRMAN-05501: aborting duplication of target database\nRMAN-06136: Oracle error from auxiliary database: ORA-17628: Oracle error 1031 returned by remote Oracle server\nORA-01031: insufficient privileges<\/code><\/pre>\n<p>It&#8217;s not clear what privilege is missing.<\/p>\n<p>RMAN debug trace gives more information:<\/p>\n<pre><code>begin sys.dbms_backup_restore.describeRemotePdb( service     =&gt; :service_in, pdbname     =&gt; :pdbname_in, descxmlfile =&gt; :descxmlfile_in); end;\nDBGSQL:             sqlcode = 17628\nDBGSQL:              B :service_in = SRCCDB\nDBGSQL:              B :pdbname_in = SRCPDB\nDBGSQL:              B :descxmlfile_in = \/u00\/oracle\/orabase\/product\/19.8.0.0.200714_a\/dbs\/_rm_pdb_pitr_2_DESTCDB.xml\nDBGSQL:          error: ORA-17628: Oracle error 1031 returned by remote Oracle server (krmkosqlerr)\nDBGSQL:          ORA-06512: at \"SYS.DBMS_BACKUP_RESTORE\", line 10817 (krmkosqlerr)\nDBGSQL:          ORA-01031: insufficient privileges (krmkosqlerr)\nDBGSQL:          ORA-06512: at \"SYS.DBMS_BACKUP_RESTORE\", line 10811 (krmkosqlerr)\nDBGSQL:          ORA-06512: at line 1 (krmkosqlerr)<\/code><\/pre>\n<p>Still not sure what the problem is, but I&#8217;ve got the idea where to look. The error ORA-17628 came from the auxiliary database, because of the ORA-01031 on the remote database. &#8220;Remote database&#8221; is the target database from the auxiliary perspective. In other words, the problem is on the target.<\/p>\n<p>There weren&#8217;t any ORA-01031 recorded in the target&#8217;s audit trail (even with audit_sys_operations=TRUE). This usually indicates that the operation bypassed the shared pool, as many Oracle C functions running under sysdba do.<\/p>\n<p>The error was registered in the alert log, though, without any details.<\/p>\n<pre><code>ORA-01031: insufficient privileges<\/code><\/pre>\n<p>I captured the call stack for getting the context:<\/p>\n<pre><code>alter system set events '1031 trace name errorstack level 3';<\/code><\/pre>\n<pre><code>kgeade()+392         call     dbkePostKGE_kgsf()   7F18758C19A0 7F1870ACFA38\n                                                   000000407 000000000 ?\n                                                   7FFF0BDC9228 ? 000000082 ?\nkgeselv()+89         call     kgeade()             7F18758C19A0 ? 7F18758C1BE8 ?\n                                                   7F1870ACFA38 ? 000000407 ?\n                                                   000000000 000000000\nksesecl0()+189       call     kgeselv()            7F18758C19A0 ? 7F1870ACFA38 ?\n                                                   000000407 ? 013666718\n                                                   013666728 F9FF4D0000000000\nkpdbcBeginClone()+5  call     ksesecl0()           7F18758C19A0 ? 7F1870ACFA38 ?\n17                                                 000000407 ? 0774C3388\n                                                   7F18759123C0 0C0040000\nkpdbksrpcswCbk()+28  call     kpdbcBeginClone()    7FFF0BDCBF62 7FFF00000009\n57                                                 7F1800000002 000000007\n                                                   000000000 000000000\nkpdbksrpcCbk()+204   call     kpdbksrpcswCbk()     7FFF0BDCBF50 7FFF00000009 ?\n                                                   7FFF0BDCBF60 7FFF0BDCD270\n                                                   000000000 ? 000000000 ?\nksrpc_sgfun()+3055   call     kpdbksrpcCbk()       000000014 7FFF0BDCD270\n                                                   7F1870C18660 7FFF0BDCD270 ?\n                                                   000000000 ? 000000000 ?\nksrpcsexec()+1315    call     ksrpc_sgfun()        000000014 7FFF0BDCFB40\n                                                   7F1870C18660 ? 7FFF0BDCD270 ?\n                                                   7F18758C1BE8 7FFF00000000\nopiodr()+1202        call     ksrpcsexec()         00000009E 000000004\n                                                   7FFF0BDCFB40 7FFF0BDCD270 ?\n                                                   7F18758C1BE8 7FFF0BDC0000\nttcpip()+1222        call     opiodr()             00000009E 000000004\n                                                   7FFF0BDCFB40 ? 000000000\n                                                   7F18758C1BE8 ? 7FFF0BDC0000 ?<\/code><\/pre>\n<p>The shared pool was bypassed. We know this, because there aren&#8217;t any parsing functions on the stack.<\/p>\n<p>ksesecl0() generated ORA-01031 due to a failed security check in kpdbcBeginClone(). I assume it&#8217;s hardcoded in kpdbcBeginClone() that it can&#8217;t be called in a sysbackup session.<\/p>\n<p>A little benefit of this analysis: we can deduce some unknown meanings in the Oracle C function naming convention:<\/p>\n<ul>\n<li>&#8220;rpc&#8221; in ksrpcsexec() and its children might mean remote procedure call, as ksrpcsexec() was called on behalf of sys.dbms_backup_restore.describeRemotePdb() in the auxiliary database.<\/li>\n<li>&#8220;sgfun&#8221; in ksrpc_sgfun() means &#8220;single function&#8221;.<\/li>\n<li>&#8220;sec&#8221; in ksesecl0 is &#8220;security&#8221;.<\/li>\n<\/ul>\n<p>In conclusion, &#8220;duplicate pluggable database&#8221; doesn&#8217;t work with sysbackup, probably because the rule is hardcoded in an Oracle C function. Since this works with non-multitenant databases, and according to the documentation it should work for pluggable databases too, it must be a bug. The only workaround I&#8217;m aware of is connecting as sysdba.<\/p>\n<p>I did this analysis on a 19.8.0.0.200714 database.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Duplicate of pluggable databases doesn&#8217;t work with SYSBACKUP. The privilege rule seems to be hardcoded in an Oracle C function. <a href=\"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/\" class=\"more-link\">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":{"inline_featured_image":false,"footnotes":""},"categories":[5,38],"tags":[],"class_list":["post-3650","post","type-post","status-publish","format-standard","hentry","category-oracle","category-rman"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Duplicating Pluggable Databases with sysbackup - All-round Database Topics<\/title>\n<meta name=\"description\" content=\"Duplicate of pluggable databases doesn&#039;t work with SYSBACKUP. The privilege rule seems to be hardcoded in an Oracle C function.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Duplicating Pluggable Databases with sysbackup - All-round Database Topics\" \/>\n<meta property=\"og:description\" content=\"Duplicate of pluggable databases doesn&#039;t work with SYSBACKUP. The privilege rule seems to be hardcoded in an Oracle C function.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/\" \/>\n<meta property=\"og:site_name\" content=\"All-round Database Topics\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-22T18:27:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-22T18:28:32+00:00\" \/>\n<meta name=\"author\" content=\"Nenad Noveljic\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@NenadNoveljic\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nenad Noveljic\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/duplicating-pluggable-databases-with-sysbackup\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/duplicating-pluggable-databases-with-sysbackup\\\/\"},\"author\":{\"name\":\"Nenad Noveljic\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\"},\"headline\":\"Duplicating Pluggable Databases with sysbackup\",\"datePublished\":\"2020-11-22T18:27:22+00:00\",\"dateModified\":\"2020-11-22T18:28:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/duplicating-pluggable-databases-with-sysbackup\\\/\"},\"wordCount\":379,\"commentCount\":0,\"articleSection\":[\"Oracle\",\"RMAN\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/duplicating-pluggable-databases-with-sysbackup\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/duplicating-pluggable-databases-with-sysbackup\\\/\",\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/duplicating-pluggable-databases-with-sysbackup\\\/\",\"name\":\"Duplicating Pluggable Databases with sysbackup - All-round Database Topics\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#website\"},\"datePublished\":\"2020-11-22T18:27:22+00:00\",\"dateModified\":\"2020-11-22T18:28:32+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\"},\"description\":\"Duplicate of pluggable databases doesn't work with SYSBACKUP. The privilege rule seems to be hardcoded in an Oracle C function.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/duplicating-pluggable-databases-with-sysbackup\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/duplicating-pluggable-databases-with-sysbackup\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/duplicating-pluggable-databases-with-sysbackup\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Duplicating Pluggable Databases with sysbackup\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/\",\"name\":\"All-round Database Topics\",\"description\":\"Nenad Noveljic\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\",\"name\":\"Nenad Noveljic\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"caption\":\"Nenad Noveljic\"},\"sameAs\":[\"nenad-noveljic-9b746a6\",\"https:\\\/\\\/x.com\\\/NenadNoveljic\"],\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/author\\\/nenad\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Duplicating Pluggable Databases with sysbackup - All-round Database Topics","description":"Duplicate of pluggable databases doesn't work with SYSBACKUP. The privilege rule seems to be hardcoded in an Oracle C function.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/","og_locale":"en_US","og_type":"article","og_title":"Duplicating Pluggable Databases with sysbackup - All-round Database Topics","og_description":"Duplicate of pluggable databases doesn't work with SYSBACKUP. The privilege rule seems to be hardcoded in an Oracle C function.","og_url":"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/","og_site_name":"All-round Database Topics","article_published_time":"2020-11-22T18:27:22+00:00","article_modified_time":"2020-11-22T18:28:32+00:00","author":"Nenad Noveljic","twitter_card":"summary_large_image","twitter_creator":"@NenadNoveljic","twitter_misc":{"Written by":"Nenad Noveljic","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/#article","isPartOf":{"@id":"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/"},"author":{"name":"Nenad Noveljic","@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa"},"headline":"Duplicating Pluggable Databases with sysbackup","datePublished":"2020-11-22T18:27:22+00:00","dateModified":"2020-11-22T18:28:32+00:00","mainEntityOfPage":{"@id":"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/"},"wordCount":379,"commentCount":0,"articleSection":["Oracle","RMAN"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/","url":"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/","name":"Duplicating Pluggable Databases with sysbackup - All-round Database Topics","isPartOf":{"@id":"https:\/\/nenadnoveljic.com\/blog\/#website"},"datePublished":"2020-11-22T18:27:22+00:00","dateModified":"2020-11-22T18:28:32+00:00","author":{"@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa"},"description":"Duplicate of pluggable databases doesn't work with SYSBACKUP. The privilege rule seems to be hardcoded in an Oracle C function.","breadcrumb":{"@id":"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nenadnoveljic.com\/blog\/duplicating-pluggable-databases-with-sysbackup\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nenadnoveljic.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Duplicating Pluggable Databases with sysbackup"}]},{"@type":"WebSite","@id":"https:\/\/nenadnoveljic.com\/blog\/#website","url":"https:\/\/nenadnoveljic.com\/blog\/","name":"All-round Database Topics","description":"Nenad Noveljic","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nenadnoveljic.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa","name":"Nenad Noveljic","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","caption":"Nenad Noveljic"},"sameAs":["nenad-noveljic-9b746a6","https:\/\/x.com\/NenadNoveljic"],"url":"https:\/\/nenadnoveljic.com\/blog\/author\/nenad\/"}]}},"_links":{"self":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/3650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/comments?post=3650"}],"version-history":[{"count":1,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/3650\/revisions"}],"predecessor-version":[{"id":3655,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/3650\/revisions\/3655"}],"wp:attachment":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/media?parent=3650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/categories?post=3650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/tags?post=3650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}