OCI - Oracle Base Database Service - Creating Custom Backups
Tags: oci, oracle, backups, rman
Published: 2024-04-14 09:33:37

[](
      <style>
        .libutton {
          display: flex;
          flex-direction: column;
          justify-content: center;
          padding: 7px;
          text-align: center;
          outline: none;
          text-decoration: none !important;
          color: #ffffff !important;
          width: 200px;
          height: 32px;
          border-radius: 16px;
          background-color: #0A66C2;
          font-family: "SF Pro Text", Helvetica, sans-serif;
        { Abhilash Kumar Bhattaram : </style> <a class="libutton" href="https://www.linkedin.com/comm/mynetwork/discovery-see-all?usecase=PEOPLE_FOLLOWS&followMember=abhilash-kumar-85b92918" target="_blank">Follow on LinkedIn</a>) }


This blog is specific to how RMAN backups are handled by Oracle Cloud Infrastructure and how custom backups are initiated. Oracle cloud databases have two kinds of Database services as below.

1. DB System 
2. ExaCS 

Lets discuss some common charecterstics of each of the above 

## RMAN Backups for OCI 

Both the class of databases work on RMAN backups , but with different tooling which will be explained in later part of the blog . However it is impotant to understand that the cloud storage for these would be located internally in OCI Internal Object storage buckets. It is important to note that  these are not the Oracle Cloud Object storage buckets that an OCI Adminstrator can create , they are "special" Object storage are in Oracle Cloud for RMAN Backups 

## OCI Backup Configurations 

The following factores need to be considered before scheduling backups 

1. The Backups schedules and retentions canbe customized , but the default is 30 days 
2. Backups can be scheduled for standby databases as well
3. Scheduling automatic Backups include archivelog backups every 30 mins and the incremental backups on weekends , hese include all components like dbfiles , control files , archivelog backups , wallets , etc.. Basically everything that you expect to run in an RMAN backup will work here.  

The Official Documentation Link for OCI Database Backups is [here](https://docs.oracle.com/en/cloud/paas/base-database/backup-db/#GUID-021D90DB-9AE2-483A-8697-B764631BE747)

## OCI DB System - Custom Backups CLI Reference

My personal preference to trigger manual backups is via **dbcli** , which is an internal tool for managing DB system which can help create custom backups. This needs tobe run as the root user of the system.

```
dbcli create-backup 
  -in <db_name> 
  -i <db_id> 
  [-bt {Regular-L0|Regular-L1|Longterm|ArchiveLog}] 
  [-c {Database|TdeWallet}] 
  [-k <n>] 
  [-t <tag>] 
  [-h] [-j]
```

The official link for dbli command reference is [here](https://docs.oracle.com/en-us/iaas/base-database/doc/oracle-database-cli-reference.html)


## OCI ExaCS - Custom Backups CLI Reference

My personal preference to trigger manual backups is via **dbaascli** , which is an internal tool for managing ExaCS which can help create custom backups. This needs tobe run as the root user of the system.

```
# /var/opt/oracle/bkup_api/bkup_api bkup_start --dbname=dbname
```

The official link for **dbaascli** command reference is [here](https://docs.oracle.com/en/cloud/paas/exadata-cloud/csexa/create-demand-backup.html#GUID-2370EA04-3141-4D02-B328-5EE9A10F66F2)


## Tooling for DB System and ExaCS - Things to Know

As seen above it is important to understand the difference in tooling for ExaCS and DB System. OCI until date has not provided any supported methods to restore across these systems. i.e. we can't restore a DB System Backup into an ExaCS or vice versa , we might see that in future. But we could move the data via Data Pump which is more like moving schemas/tables but not the entire database with it's parameters.


The storage retention policy for OCI Databases as per documentation is below. A Customer is free to choose from the below. It is understood that more teh retention the relevant Object Storage charges would apply

```
Bronze (14 days)
Silver (35 days) (default)
Gold (65 days)
Platinum (95 days)
Custom (User defined protection policy)
```


## Custom Schedules - Workaround

I had a customer requirement to take a full backup of the database on every third week Tuesday for a compliance requirement. Such schedules are not available in Oracle Cloud Infrastructire but I had a easy workaround using crontab schedules to handle them 

```
# Cron Backup to run on third Tuesday 
00 23 15-22 * *  [ $(date +'\%w') -eq 2 ] && /home/oracle/backup_script.sh >> /backup/dbname_backuplog_$(date +'%Y-%m-%d-%HH:%M:%S').log 2>&1
```

NOTE : The backup_script.sh is a wrapper script used for dbcli and dbaascli , such workarounds are very convenient to use for customized backup. There would be no change in the way backups are handled and stored with a custom backup. They continue to use the same Object storage mechanism as used for the Oracle Cloud Automatic Backups. The working and scheduling of Oracle Cloud automatic backups is documented [here](https://docs.oracle.com/en/cloud/paas/base-database/backup-db/#GUID-021D90DB-9AE2-483A-8697-B764631BE747)