Remote Cloning OCI DBCS PDB with OCI CLI

In previous post I showed how to perform remote clone with Resource Manager/Terraform/Ansible. What if you just want a quick remote clone to be done manually?

Remember OCI Console doesn’t support Remote Cloning at the moment (February 2022) but you can do the remote clone through API’s as well. So let’s do it with OCI CLI!

Command to clone is very simple as you can see below:

simo@cloudshell:~ (us-ashburn-1)$ oci db pluggable-database remote-cloneUsage: oci db pluggable-database remote-clone [OPTIONS]

Error: Missing option(s) --target-container-database-id, --source-container-db-admin-password, --cloned-pdb-name, --pluggable-database-id.

Only options I need to define are target-container-database-id, source-container-db-admin-password, cloned-pdb-name and pluggable-database-id (source), right? WRONG!

I ran above command but it kept saying that I’m missing few parameters. Looking CLI documentation I need to define following parameters:

  • --cloned-pdb-name 
  • --pdb-admin-password 
  • --pluggable-database-id 
  • --source-container-db-admin-password 
  • --target-container-database-id 
  • --target-tde-wallet-password 

After defining them and running CLI I see the job has been created:

simo@cloudshell:~ (us-ashburn-1)$ oci db pluggable-database remote-clone --target-container-database-id ocid1.database.oc1.iad.12345 --source-container-db-admin-password Password123 --cloned-pdb-name MY_pdb1 --pluggable-database-id ocid1.pluggabledatabase.oc1.iad.12345 --pdb-admin-password Password123 --target-tde-wallet-password Password123


{
  "data": {
    "compartment-id": "ocid1.compartment.oc1..12345",
    "connection-strings": null,
    "container-database-id": "ocid1.database.oc1.iad.12345",
    "defined-tags": {},
    "freeform-tags": {},
    "id": "ocid1.pluggabledatabase.oc1.iad.12345",
    "is-restricted": null,
    "lifecycle-details": null,
    "lifecycle-state": "PROVISIONING",
    "open-mode": "READ_WRITE",
    "pdb-name": "MY_pdb1",
    "time-created": "2022-02-23T17:42:59.089000+00:00"
  },
  "etag": "806984a2",
  "opc-work-request-id": "ocid1.coreservicesworkrequest.oc1.iad.12345"
}

After a short wait – I can see my new PDB being available in the destination CDB. You can use CLI to monitor the status, OCI Console didn’t really show the work request status properly.

s_vilmunen@cloudshell:~ (us-ashburn-1)$ oci work-requests work-request  get --work-request-id ocid1.coreservicesworkrequest.oc1.iad.12345
{
  "data": {
    "compartment-id": "ocid1.compartment.oc1..12345",
    "id": "ocid1.coreservicesworkrequest.oc1.iad.12345",
    "operation-type": "Remote Clone Pluggable Database",
    "percent-complete": 100.0,
    "resources": [
      {
        "action-type": "CREATED",
        "entity-type": "pluggableDatabase",
        "entity-uri": "/20160918/pluggableDatabases/ocid1.pluggabledatabase.oc1.iad.12345",
        "identifier": "ocid1.pluggabledatabase.oc1.iad.12345"
      }
    ],
    "status": "SUCCEEDED",
    "time-accepted": "2022-02-23T17:42:59.166000+00:00",
    "time-finished": "2022-02-23T17:57:15.400000+00:00",
    "time-started": null
  }
}

Easy way to use CLI to clone your PDB – just the CLI required parameters should be fixed!

Simo

View Comments

  • Hi Simo,
    thanks for this post. But we have the following situation:
    We have two OCI database systems PROD and TEST, each contains only one pluggable database.
    Is there any option to clone pdbprod into existing pdbtest? So just only "replace data" because we need to keep OCID a database connection string of the current pdbtest.
    We would have to rewrite connection string on all clients if new pdbtest will be created.
    Regards,
    Petr

    • Hey Petr,

      sorry for replying so late! I guess the only thing you could do is to drop the existing PDB first and then create new one with same name. But the OCID would change for sure, wouldn't the connect string stay the same? Or if you create additional service name for the PDB so then you use always that for the new/cloned PDB?

  • Hi Simo,
    i have done it earlier by the same way as you mentioned by drop existing PDB first and then create new one with same name :)
    Thanks,
    Petr

Recent Posts

Connecting to Autonomous Database Running on Google Cloud

Last time I showed how to provision Autonomous Database Serverless (ADB-S) on Google Cloud. This…

1 month ago

Can you believe it? Provisioning Autonomous Database in GCP!

I bet few years back folks didn't expect that by 2024 we would be able…

1 month ago

IP Address Insights with CLI

My previous post on IP Address Insights I mentioned it wasn't yet available with CLI…

6 months ago

Thoughts on Oracle Database@Azure

This will NOT be a technical walkthrough on Oracle Database@Azure but rather my opinions and…

6 months ago

OCI Vulnerability Scanning Setup

Many times when you work for someone, they already have their own vulnerability scanning throughout…

6 months ago

OCI IP Address Insights

Recently OCI announced small but VERY useful service, IP Address Insights. Why this matters? I've…

6 months ago