From on premise or from any OCI instance we can directly backup Oracle database using RMAN to Object Storage. 

Create new OCI bucket to store RMAN backup.

On the landing page, click on Create Bucket to create new bucket.

Provide the name of Bucket, leave everything default and click on Create Bucket.

Click on Bucket name to upload a file. The Object storage URL is required to install oci. Upload a file and view the Object Detail.

Click on Upload.

Once the upload is completed, we can view status as Finished. Click on Close.

Click on three vertical dots at the right of the object.

Click on View Object Details to view the details of the object.

Now we can see the URL Path, Please note the URL Path. URL path is in the syntax https://objectstorage.<region_name>.oraclecloud.com. For my case https://objectstorage.us-ashburn-1.oraclecloud.com.

Create API key and add key to OCI.

Create a directory to store API key.

mkdir -p /home/oracle/oci/keys

cd /home/oracle/oci/keys

Execute openssl command to create a private API key.

openssl genrsa -out oci_api_key.pem 2048

Execute openssl command to create a public API key.

openssl rsa -pubout -in oci_api_key.pem -out oci_api_key_public.pem

Copy the content of the Public API key

cat oci_api_key_public.pem

Click on the profile icon. Click on username.

Click on API Keys option under Resources in bottom left.

On API Keys page click on Add Public Key button.

Click on PASTE PUBLIC KEYS, Paste the key in the text area, and click on Add to add public keys.

Note the Fingerprint value. This value will be required to install OCI library.

Install OCI library to backup database to OCI object storage.

Download opc_installer.zip file from URL https://www.oracle.com/database/technologies/oracle-cloud-backup-downloads.html. Once the installer file is downloaded, unzip it.

unzip opc_installer.zip

Check if Java is installed in your machine. Make sure java is installed and the version is greater than or equal to 1..

which java

java -version

Create directories to store library files and encryption key files.

mkdir /home/oracle/oci/lib

mkdir /home/oracle/oci/wallet

Install OCI using command below. Please provide the config file location. This location can be any and all the details are written on the configFile. This file will be used while defining the SBT channel inside RMAN. Please note OCI tenancy ocid, OCI user ocid, Fingerprint value,  API key file location, URL of the object storage, and name of the bucket. Provide all these details. Use the lib directory and wallet directory created in the earlier section.

java -jar oci_install.jar \

  -configFile /home/oracle/oci/configfile.ora \

  -host https://objectstorage.******1.oraclecloud.com \

  -pvtKeyFile /home/oracle/oci/keys/oci_api_key.pem \

  -pubFingerPrint ********:****:57 \

  -tOCID ocid1.tenancy.oc1..************************************ \

  -uOCID ocid1.user.oc1..*************************************** \

  -libDir /home/oracle/oci/lib \

  -walletDir /home/oracle/oci/wallet \

  -bucket RMAN_BACKUP

Check library and wallet directory content to make sure library files and encryption wallet key files are placed under them.

cd /home/oracle/oci/lib

ls

cd ../wallet

ls

Check the library file and the configuration file. These files are used while defining SBT driver.

Configure RMAN channel and start database backup.

Now login to rman.

rman target /

Verify existing configuration.

show all;

Configure channel from sbt device with command below.

configure channel device type sbt parms=’SBT_LIBRARY=/home/oracle/oci/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/home/oracle/oci/configfile.ora)’;

Backup database using the command below.

backup device type sbt database;

Once backup is completed, it looks something like below. 

By mithun

One thought on “How to Backup Oracle database to OCI Object storage”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.