Create a Backup of the Source Database

Configure RMAN to create a backup of the source database and to use Oracle Database Backup Cloud Service for storage.

Install Oracle Database Backup Cloud Service on the Source Database

Install Oracle Database Backup Cloud Service on the source database to enable RMAN to recognize the object storage service. The module simulates a tape backup device on the source database.

Before you get started, collect the following information that is needed to install Oracle Database Backup Cloud Service:

  • Tenancy OCID

    In the Console, click Administration, then Tenancy Details.

  • The Compartment OCID of the compartment where the Oracle Cloud Infrastructure Object Storage bucket is located.

    In the Console, select Identity, then Compartments. Navigate to the compartment to get to the details page. The OCID is in Compartment Information.

  • Your User OCID

    In the Console, click the Profile icon, select User Information, then User Settings.

  • Your account region

    The region is part of the Console's URL. For example in https://console.us-ashburn-1.oraclecloud.com, the region ID is us-ashburn-1.

  1. Log in as the oracle user on the source database.
  2. Install the oci_install.jar file and complete the region ID, public key fingerprint, tenancy OCID, user OCID, Compartment OCID, and bucket name that you created earlier and provide directories for the library, wallet, and private key file.
    java -jar oci_install.jar \
    -host https://objectstorage.region.oraclecloud.com \
    -pubFingerPrint wallet_public_key_fingerprint \
    -tOCID tenancy_OCID \
    -uOCID user_OCID \
    -cOCID compartment_OCID \
    -libDir $ORACLE_HOME/lib \
    -walletDir $ORACLE_HOME/data/wallet \
    -pvtKeyFile $ORACLE_HOME/data/wallet/oci_pvt \
    -bucket bucket_name \
    -configFile ~/config

    This will install the Database Cloud Backup libraries in the $ORACLE_HOME/lib directory and create a configuration file named config in the home folder of the oracle user, which contains configuration settings to access the Object Storage bucket and encrypt the backup files.

  3. Switch to ARCHIVE_LOG mode if not open.

Set the Database Archiving Mode

To successfully backup the database, the database must be in ARCHIVELOG mode.

Changing the archive mode will shut down the database.

  1. Start RMAN and connect to the source database.
    rman target / 
  2. Check the database's log mode.
    RMAN> select log_mode from v$database;
    • If the output is ARCHIVELOG, then the mode is already set.
    • If the output is NOARCHIVELOG, then proceed to the next step to change the archiving mode.
  3. Change the archiving mode to ARCHIVELOG.
    The database is shutdown before changing the archive mode.
    RMAN> run {
    shutdown immediate;
    startup mount;
    alter database archivelog;
    alter database open;
    }
  4. Verify that the archiving mode is set to ARCHIVELOG.

Configure the Backup Storage Device and Criteria

Configure RMAN for the backup storage device, in this case it's Oracle Database Backup Cloud Service posing as a tape backup (SBT_TAPE).

An RMAN channel represents one stream of data to a device type, and corresponds to one server session. For the BACKUP command, RMAN allocates only a single type of channel, such as DISK or SBT (Serial Backup Tape). Configure SBT_TAPE so that RMAN backups are sent to Oracle Database Backup Cloud Service instead of to disk.

Before you begin, you'll need the value for your ORACLE_HOME environment variable and the location of the config file generated when you installed Oracle Database Backup Cloud Service on the source database.
  1. Using RMAN, connect to the CDB database to get the database ID (DBID) number.
    RMAN> connect target sys@orclcdb
    target database Password:

    The output includes the DBID, save the DBID number, you'll need it later.

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

    Under target where setting DBIDs, emphasize that target dbid is being replaced with source DBID via RMAN, as show under “Set the DBID and Restore the SPF File From Backup”

    When defining the SBT_Library, use your ORACLE_HOME environment variable.

    When defining the SBT_PARMS, the OPC_PFILE is the location of the config file ( /home/oracle/config).

    For example, the following command uses the target database control file instead of the recovery catalog:

    RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 
    'SBT_LIBRARY=/opt/oracle/product/19c/dbhome_1/lib/libopc.so,
    SBT_PARAMS=(OPC_PFILE=/opt/oracle/product/19c/dbhome_1/dbs/opcora19c.ora)';
  3. Configure RMAN to use SBT_TAPE as the default backup location and configure encryption.

    There are other settings that may apply to your installation such as compression, number of backup and recovery channels to use, backup retention policy, and archived log deletion policy.

    See the Oracle Backup and Recovery documentation for your version of Oracle for more information on choosing the appropriate settings.

    For example, the following command enables the controlfile and spfile autobackup to use SBT_TAPE and configures encryption for Oracle Database version 19c:
    RMAN> run {
    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;
    }
    
  4. Set the encryption password used to encrypt the backup data before sending to the storage bucket.
    RMAN> SET ENCRYPTION IDENTIFIED BY password ONLY;

Backup the Source Database

Backup the source database to Oracle Database Backup Cloud Service.

Determine the type of backup to perform: a full backup (level 0) or an incremental backup (level 1). The type of backup and the amount of data will determine the amount of time needed to backup the database.

  1. Perform a full backup.

    For example:

    RMAN> BACKUP INCREMENTAL LEVEL 0 SECTION SIZE 512M DATABASE PLUS
          ARCHIVELOG;
  2. Optionally, you can perform an incremental backup (level 1) instead of a full backup.
    You can define the section size:
    RMAN> BACKUP INCREMENTAL LEVEL 1 SECTION SIZE 512M DATABASE PLUS
          ARCHIVELOG;

    or, you might want to define the cumulative section size:

    RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE SECTION SIZE 512M DATABASE PLUS
          ARCHIVELOG;