How to take RMAN Backup on DBCS in OCI to Object Storage


We are going to learn how we can take a RMAN backup on DBCS and store it in Object storage bucket in OCI


Source System Information:


DB version: 11.2.0.4

DB on OCI DBCS

Type of Database : Oracle EBS

Single Node



Steps:


1) Create an OCI Private bucket to store RMAN backup.


Click on Navigation Menu > Object Storage > Object Storage > Buckets

 







2) As My OCI region is singapore so my Object_Storage URL: 


https://objectstorage.ap-singapore-1.oraclecloud.com


Bucket Name: PROD_RMAN_BACKUP



3) Connect to DBCS System Database Node


login as: opc
sudo su - oracle


4) Create API key and add key to OCI

Create a directory to store API key.

mkdir -p /home/oracle/oci_new/keys

cd /home/oracle/oci_new/keys

Execute openssl command to create a private API key.

[oracle@foadbserver keys]$ openssl genrsa -out oci_api_key.pem 2048

Generating RSA private key, 2048 bit long modulus

........+++

................+++

e is 65537 (0x10001)

Execute openssl command to create a public API key.


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


[oracle@foadbserver keys]$ openssl rsa -pubout -in oci_api_key.pem -out oci_api_key_public.pem

writing RSA key

Copy the content of the Public API key

cat oci_api_key_public.pem

Go to the user and 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.



5) Change to the directory that contains the backup module oci_install.jar file.


Download from below link.


URL https://www.oracle.com/database/technologies/oracle-cloud-backup-downloads.html



-rw-r--r-- 1 oracle oinstall 1816114 Feb  1 13:03 opc_installer.zip

[oracle@foadbserver oci_new]$ unzip opc_installer.zip



Also make sure java is installed on java. The version need to be correct. Don't install a higher version.


yum install java


[opc@foadbserver ~]$ which java

/usr/bin/java

[opc@foadbserver ~]$ java -version

java version "1.8.0_371"

Java(TM) SE Runtime Environment (build 1.8.0_371-b11)

Java HotSpot(TM) 64-Bit Server VM (build 25.371-b11, mixed mode)


5) Create directories to store library files and encryption key files.


mkdir /home/oracle/oci_new/lib


mkdir /home/oracle/oci_new/wallet




6) Install backup Module:


First make sure ntp is running



NTP Installation and Configuration

[root@foadbserver ~]# yum -y install ntp 
[root@foadbserver ~]# systemctl start ntpd 
[root@foadbserver ~]# systemctl enable ntpd


cd /home/oracle/oci_new/opc_installer/oci_installer    --> Location where the installer is present.


Syntax:



java -jar oci_install.jar \

-configFile /home/oracle/oci_new/config_file.ora \

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

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

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

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

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

-libDir /home/oracle/oci/lib \

-walletDir /home/oracle/oci/wallet \

-bucket RMAN_BACKUP



host ==> https://objectstorage.<region>.oraclecloud.com



Bucket Name








Output:





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


cd /home/oracle/oci_new/lib

ls


cd ../wallet

ls



8) Configure RMAN



Using Oracle user on DBCS node.


rman target /


Configure RMAN to use the SBT device and point to the config file that was created when you installed the backup module. 

CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/home/oracle/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/home/oracle/config)';


CONFIGURE DEFAULT DEVICE TYPE TO SBT_TAPE;

CONFIGURE BACKUP OPTIMIZATION ON;

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO '%F';

CONFIGURE ENCRYPTION FOR DATABASE ON;

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;


More configuration can be changed based on requirements.



Sample RMAN Script


rman target / log=~/logs/proddb_${DATE}.log << EOF

SET ENCRYPTION IDENTIFIED BY "funebs123" ONLY;  -->Every Time we run we need to set this.

run

{

ALLOCATE CHANNEL c1 DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/home/oracle/oci_new/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/home/oracle/oci_new/config_file.ora)';

backup current controlfile format 'PROD_control_%d_%U.ctl';

BACKUP FORMAT PROD_full_%d_%u_%s_%p'  DATABASE  SPFILE  FORMAT 'PROD_SPFILE_%d_%u_%s_%p' PLUS ARCHIVELOG   FORMAT PROD_ARCH_%d_%u_%s_%p';

release channel ch1;

}

EOF




Full Sample Script

#!/bin/bash
########################################
####Created by Himanshu ###
#############02-JAN-2023################
. /home/oracle/.bash_profile
export DATE=$(date +%y-%m-%d_%H%M%S)
/u01/app/oracle/product/11.2.0.4/dbhome_1/bin/rman target / log=/home/oracle/logs/proddb_${DATE}.log << EOF
SET ENCRYPTION IDENTIFIED BY "foadbbackup23" ONLY;
run
{
  ALLOCATE CHANNEL c1 DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/home/oracle/oci/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/home/oracle/config)';
  ALLOCATE CHANNEL c2 DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/home/oracle/oci/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/home/oracle/config)';
  ALLOCATE CHANNEL c3 DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/home/oracle/oci/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/home/oracle/config)';
  ALLOCATE CHANNEL c4 DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/home/oracle/oci/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/home/oracle/config)';
delete noprompt obsolete;
backup current controlfile format 'PROD_control_%U.ctl';
BACKUP AS COMPRESSED BACKUPSET TAG 'WEEEKLY_FULL_DB_MANUAL' DATABASE format 'PROD_full_%u_%s_%p' PLUS ARCHIVELOG format 'PROD_Arch_%u_%s_%p';
  RELEASE CHANNEL c1;
  RELEASE CHANNEL c2;
  RELEASE CHANNEL c3;
  RELEASE CHANNEL c4;
}
EOF






If you like please follow and comment