Monday, June 3, 2024

OCI DBCS : Backup using OCI backup module

 







Intro 

We live in a cloud era and Many organizations across various industries are leveraging cloud technology to enhance their operations, improve scalability, increase flexibility, and reduce costs. Last few years Oracle has been making significant progress on hosting database workload in Oracle Cloud Infrastructure. Also provides many cloud services and Many companies use Oracle Object storage to store their database backups.

Backing an Oracle database for object storage is a common practice for ensuring data durability, accessibility, and scalability. Object storage services, such as Amazon S3, Google Cloud Storage, or Azure Blob Storage, offer a reliable and cost-effective solution for storing backups securely offsite.

Oracle Object Storage is a cloud-based storage solution provided by Oracle Corporation as part of its Oracle Cloud Infrastructure (OCI) offerings. It provides a scalable, durable, and highly available storage platform for storing various data types, including files, objects, and unstructured data.

Organizations are heavily using Oracle Base Database Service to migrate Oracle database workload. Because DBCS is a robust environment and fully managed database service, Oracle takes care of tasks such as hardware provisioning, software installation, patching, backups, and maintenance. This allows organizations to focus on using the database rather than managing the underlying infrastructure.

But recently DBCS stopped supporting older database version 12c. This limits you to not having an automatic backup feature.

Oracle Base Database Service supports the following Oracle Database versions: 
  • Oracle Database 23c
  • Oracle Database 21c
  • Oracle Database 19c
So, the only option left was to migrate database backups to object storage bucks. The easiest way to perform this using the OCI backup module.   

What is the OCI backup module? 

OCI Backup is a module within the Oracle Cloud Infrastructure (OCI) platform that offers comprehensive data protection and backup capabilities for workloads running on OCI. It provides users the tools and services to protect critical data and ensure business continuity. Here's an overview of OCI Backup:

You can use this below-mentioned link to configure OCI automatic backups 

https://docs.oracle.com/en/cloud/paas/db-backup-cloud/csdbb/installing-oracle-database-cloud-backup-module-oci.html#GUID-8BAB6043-F8BD-44CE-AED3-87B57743AE72

The software can be downloaded using: https://www.oracle.com/database/technologies/oracle-cloud-backup-downloads.html


In this article, I will illustrate the steps of how you can configure backup to point to OCI object storage. 

To install this module you need to check if Java is installed on your machine. Make sure java is installed and the version is greater than or equal to 1.7.

Download and Stage OCI backup Module :

Created a folder to store the backup files for this example we created the folder called: /home/oracle/bkp_tool and stage OCI Backup Module installation. Once you unzip there will be two folders called oci_installer and opc_installer.


[oracle@dbsdpl21 bkp_tool]$ ls -lrth opc_installer.zip
-rwxr-xr-x 1 oracle oinstall 1.8M Mar 19 18:11 opc_installer.zip
[oracle@dbsdpl21 bkp_tool]$ ls -l opc_installer
total 12
drwx------ 2 oracle oinstall 4096 Oct 18  2019 oci_installer
drwxr-xr-x 2 oracle oinstall 4096 Oct 18  2019 opc_installer
-rwxr-xr-x 1 oracle oinstall 1623 Feb 12  2019 readme.txt
[oracle@dbsdpl21 bkp_tool]$ ls -l opc_installer/oci_installer
total 968
-rw-r--r-- 1 oracle oinstall 971147 Oct 17  2019 oci_install.jar
-rw-r--r-- 1 oracle oinstall  15204 Oct 18  2019 oci_readme.txt
[oracle@dbsdpl21 bkp_tool]$




Installation

Once you stage execute "java -jar oci_install.jar -help" to understand which parameters you need for the installation.



[oracle@dbsdpl21 oci_installer]$ java -jar oci_install.jar -help
Oracle Database Cloud Backup Module Install Tool, build 19.3.0.0.0DBBKPCSBP_2019-10-16
No arguments supplied
Usage: java -jar oci_install.jar
        -host;           OCI host name
        -pvtKeyFile:     OCI API private key file name
        -pubFingerPrint: OCI API public key finger print
        -tOCID:          OCI tenancy OCID
        -uOCID:          OCI user OCID
        -bucket:         OCI bucket to store backups
        -cOCID:          OCI resource compartment ID
        -newRSAKeyPair:  Set up new RSA key pair for authentication
        -enableArchiving: Enable archival.
        -archiveAfterBackup:
                         The timeline after which to archive
                         backups.
        -retainAfterRestore :
                         The number of hours after which
                         object is retained in standard storage
                         before it is sent back to archival, post the
                         restore.
        -displayBucketAttrs :
                         Display bucket properties
        -trace :         Enable Tracing
        -walletDir:      Directory to store wallet
        -trustedCerts:   SSL certificates to be imported
        -import-all-trustcerts:
                         Import all certificates from Java truststore
        -configFile:     File name of config file
        -libDir:         Directory to store library
        -libPlatform:    Platform of library to download
        -lib-download-only:
                         Download library only
        -proxyHost:      HTTP proxy host
        -proxyPort:      HTTP proxy port
        -proxyID:        HTTP proxy userid, if needed
        -proxyPass:      HTTP proxy password, if needed
        -argFile:        File name of arguments file
        -help:           Print this usage information and exit

Oracle Database Cloud Backup Module Install Tool.

This utility installs the credentials and software that are
required to use the Oracle Cloud Infrastructure (OCI) Backup
Service library.

The following parameters can be specified:

-host:           Host name for the OCI account.

-pvtKeyFile:     Private key used to sign OCI API requests.
                 The key file must be in PEM format.

Note that your private key used for OCI API request authentication
is never transmitted outside of the computer where the install
utility is running.

-pubFingerPrint: Finger print of the public key paired with the
                 specified private key. The finger print tells OCI
                 which private and public key pair is used to
                 authenticate OCI API requests.

-tOCID:          The tenancy OCID for the OCI account.

-uOCID:          The user OCID for the OCI account.

-bucket:         The name of the bucket where the backup will go.

Note that the install tool will create the specified bucket if it
does not exist. If the parameter is not specified, RMAN interface
library will automatically create a bucket to store backups.

-cOCID:          The resource comparment ID for the OCI account.
                 The default value is the tenancy OCID if not
                 specified.

-newRSAKeyPair:  Set up a new pair of public and private RSA keys
                 for authentication. If specified, the install tool
                 will generate a random RSA private and public key
                 pair of 2048 bits and outputs them in the
                 specified Oracle Wallet directory.

-enableArchiving:  Enable archival. If specified the value should
                 be either TRUE/true OR FALSE/false. By default the
                 archival is disabled.

-archiveAfterBackup: The timeline after which backups from a
                 container would be archived.
                 This parameter is only effective when the
                 enableArchiving parameter is specified. This should
                 be specified as [timeAmount timeUnit] such as
                 "4 days", "52 years". By default this value
                 will be set to 0 days.

-retainAfterRestore: The number of hours after which backups
                 from a container would be sent back to archival
                 storage once it is restored on to standard storage.
                 This parameter is only effective when the
                 enableArchiving parameter is specified. This should
                 be specified as [timeAmount timeUnit] such as
                 "24 hours", "48 hours". By default the number
                 of hours will be set to 48.
                 It is recommended to keep this considerably large
                 so that the restored data from archival storage
                 is retained in standard storage till the actual
                 restore is completed. There is a risk of data
                 resent back to archival storage if the value is
                 low. Recommended setting is 48 hours.
-displayBucketAttrs: Display storage bucket properties
                 Not recommended to be used while creating bucket.
-trace : Enable Tracing

-walletDir:      The directory where the install tool
                 will create an Oracle Wallet containing
                 your service authorization credentials.
                 This parameter is required.

-trustedCerts:   List of SSL certificate to be imported into
                 the Oracle Wallet

-configFile:     The name of the initialization parameter file
                 that will be created by the install tool.
                 This parameter file will be referenced during your
                 RMAN jobs. If this parameter is not specified,
                 then the initialization parameter file will
                 be created in a system-dependent default location.

-libDir:         The directory where the install tool will
                 download the RMAN interface library. This
                 parameter is optional. If not specified, then
                 the RMAN interface library will not be downloaded.

-libPlatform:    The platform of the RMAN interface library that
                 is required.  This is optional, and is normally
                 not needed because the install tool will determine
                 the correct platform automatically by examining
                 the system where the tool is running.

                 This version of the install tool supports the
                 following platform values:
                   linux64, windows64, solaris_sparc64, solaris_x64, zlinux64, hpux_ia64, aix_ppc64

-lib-download-only:
                 Download only the RMAN interface library

-proxyHost:      HTTP proxy server, if needed.

-proxyPort:      HTTP proxy server connection port, if needed.

-proxyId:        Username for HTTP proxy server, if needed.

-proxyPass:      Password for HTTP proxy server, if needed.

-argFile:        Read arguments from specified file. Specify filename
                 as "-" to read arguments from standard input.

-import-all-trustcerts:
                 Import all X509 certificates from Java truststore.

-help:           Print this usage information and exit.
[oracle@dbsdpl21 oci_installer]$



We need to pass the below-mentioned parameters to install the OCI backup module.



 java -jar oci_install.jar -host -object-storage-url-path- \
-pvtKeyFile -location-private-key- \
-pubFingerPrint -finger-print- \
-uOCID -oci_user_id- \
-tOCID -oci_tenancy_id- \
-cOCID -oci_compartment_id- \
-walletDir -wallet_file_location- \
-libDir -libary-path-location- \
-configfile -configuration-file- \
-bucket -bucket-name-
  


Pre-requisites

We need the below-mentioned prerequisites to configure the OCI Backup module.

  1. JDK 1.7 or later on the system you plan to install the Oracle Database Cloud Backup.
  2. Need to set up the user to get the private and fingerprint.
  3. Need to create an object storage bucket for backups.
  4. Create a configuration file related object bucket and wallet file location.

Validate Java Version :

  
[oracle@dbsdpl21 ~]$ java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
[oracle@dbsdpl21 ~]$

Add user and configure API Key.


 
We need to set the user to get the fingerprint and private key. Navigate to the profile and select API keys.


                                                  Figure 1: Navigate to profile 

   Now select the API keys and  Add API keys.       


                                                Figure 2: Select API keys.


Configure Object storage 

Now configure the object storage bucket for backups.


                                               Figure 3: Configure Object storage bucket.

Create configuration file 

We need a configuration file mentioning all the backup and wallet file-related information. Under /home/oracle/bkp_tool/  we need to create two folders oci_wallet and lib.

Sample of the configuration file.



[oracle@dbsdpl21 bkp_tool]$ cat opcora19c.ora
OPC_HOST=https://objectstorage.ca-toronto-1.oraclecloud.com/n/xxxxx
OPC_WALLET='LOCATION=file:/home/oracle/bkp_tool/oci_wallet CREDENTIAL_ALIAS=alias_oci'
OPC_CONTAINER=rman_backup
OPC_COMPARTMENT_ID=ocid1.compartment.oc1..xxxxxx
OPC_AUTH_SCHEME=BMC
[oracle@dbsdpl21 bkp_tool]$
  
  


Install backup module


This is the sample of the backup installation. Once the installation is complete you can run a backup and check the object storage.

  
[oracle@dbsdpl21 oci_installer]$ java -jar oci_install.jar -host https://objectstorage.ca-toronto-1.oraclecloud.com \
> -pvtKeyFile /home/oracle/.ssh/oci-backup-priv.pem \
> -pubFingerPrint 33:44:73:fe:b7::xx:xx:xx:xx \
> -uOCID ocid1.user.oc1..xxxxxxxx \
> -tOCID ocid1.tenancy.oc1..xxxxxxxxx \
> -cOCID ocid1.compartment.oc1..xxxxxxxxxxx \
> -walletDir /home/oracle/bkp_tool/oci_wallet \
> -libDir /home/oracle/bkp_tool/lib \
> -configfile /home/oracle/bkp_tool/opcora19c.ora \
> -bucket rman_backup
Oracle Database Cloud Backup Module Install Tool, build 19.3.0.0.0DBBKPCSBP_2019-10-16
Oracle Database Cloud Backup Module credentials are valid.
Backups would be sent to bucket rman_backup.
Oracle Database Cloud Backup Module wallet created in directory /home/oracle/bkp_tool/oci_wallet.
Oracle Database Cloud Backup Module initialization file /home/oracle/bkp_tool/opcora19c.ora created.
Downloading Oracle Database Cloud Backup Module Software Library from Oracle Cloud Infrastructure.
Download complete.
[oracle@dbsdpl21 oci_installer]$
  
  

Configure RMAN

Once the OCI backup module installation is complete, you can configure the rman to point to object storage, configure command is mentioned below.


RMAN configuration:

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





RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS  'SBT_LIBRARY=/home/oracle/bkp_tool/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/home/oracle/bkp_tool/opcora19c.ora)';
using target database control file instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' FORMAT   '%d_%I_%U_%T_%t' PARMS  'SBT_LIBRARY=/opt/oracle/dcs/commonstore/oss/PWSH01_yyz16x/libopc.so ENV=(OPC_PFILE=/opt/oracle/dcs/commonstore/oss/PWSH01_yyz16x6668da22-daae-464d-89dd-52b47216199d/opc_PWSH01_yyz16x.ora)';
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS  'SBT_LIBRARY=/home/oracle/bkp_tool/lib/libopc.so, SBT_PARMS=(OPC_PFILE=/home/oracle/bkp_tool/opcora19c.ora)';
new RMAN configuration parameters are successfully stored

Backup control file




For testing you can backup the current control file and validate the object storage.


RMAN> backup current controlfile;

Starting backup at 20-MAR-24
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=1085 instance=PWSH011 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Database Backup Service Library VER=19.0.0.1
allocated channel: ORA_SBT_TAPE_2
channel ORA_SBT_TAPE_2: SID=173 instance=PWSH011 device type=SBT_TAPE
channel ORA_SBT_TAPE_2: Oracle Database Backup Service Library VER=19.0.0.1
allocated channel: ORA_SBT_TAPE_3
channel ORA_SBT_TAPE_3: SID=330 instance=PWSH011 device type=SBT_TAPE
channel ORA_SBT_TAPE_3: Oracle Database Backup Service Library VER=19.0.0.1
allocated channel: ORA_SBT_TAPE_4
channel ORA_SBT_TAPE_4: SID=476 instance=PWSH011 device type=SBT_TAPE
channel ORA_SBT_TAPE_4: Oracle Database Backup Service Library VER=19.0.0.1
channel ORA_SBT_TAPE_1: starting compressed full datafile backup set
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_SBT_TAPE_1: starting piece 1 at 20-MAR-24
channel ORA_SBT_TAPE_1: finished piece 1 at 20-MAR-24
piece handle=9p2m65s9_11577_1_1 tag=TAG20240320T151313 comment=API Version 2.0,MMS Version 19.0.0.1
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:03
Finished backup at 20-MAR-24

Starting Control File and SPFILE Autobackup at 20-MAR-24
piece handle=c-3893281384-20240320-22 comment=API Version 2.0,MMS Version 19.0.0.1
Finished Control File and SPFILE Autobackup at 20-MAR-24

RMAN>


Validate

Once the backup is complete, you can validate the backup piece from the object storage bucket.





Conclusion

In summary, the OCI backup module plays a crucial role in helping organizations protect their data, meet compliance requirements, ensure business continuity, manage risks, and optimize costs. By leveraging the capabilities of OCI backup services, organizations can enhance their data protection strategies and safeguard their valuable assets effectively.

No comments:

Post a Comment

Oracle world 2024 - AI

  Intro  The world is transitioning from the data era to the age of artificial intelligence. Many organizations are leveraging AI features t...