Learn About Configuring Oracle Database Backups

Back up an on-premises database into an OCI Object Storage bucket.

Install Oracle Database Backup Module on the Source Database

Back up to OCI by first installing the Oracle Database Cloud Backup Module for OCI.

Download the module (see Before You Begin) and install it on your database server.
  1. Install the module on the source database server.
  2. Change the directory to oci_installer, which has the JAR file.
  3. Install the JAR file.
  4. Fill in:
    • Region ID
    • Public key fingerprint
    • Tenancy OCID
    • User OCID
    • Compartment OCID
    • Bucket name that you created earlier
  5. Provide directories for:
    • Library
    • Wallet
    • Private key file
    java -jar oci_install.jar \ 
    -host https://objectstorage.us-langley-1.oraclegovcloud.com -pvtKeyFile /tmp/-01-31-22-38.pem \ 
    -pubFingerPrint 2k:cd:cv:71:6f:ab:6f:xz:ef:72:gh:cc \ 
    -uOCID ocid1.user.oc2..aaaaaabc \ 
    -tOCID ocid1.tenancy.oc2..aaaaadef \ 
    -walletDir $ORACLE_HOME/lib/oci_wallet \
    -libDir $ORACLE_HOME/lib -bucket bucket-20230131-1601-modbac \ -cOCID ocid1.compartment.oc2..aaaaaghi

    To capture fingerprint, tenancy, user OCIDs, and government-specific endpoints, see Explore More. For compartment OCID navigate to Identity and Security and under Identity compartments, click on the compartment you want the OCID and copy the OCID.

Configure RMAN to Support Cloud Backups

After you install the required backup module and configure Recovery Manager (RMAN) settings, you can create backups using familiar RMAN commands. Information about your cloud backups is maintained in the database control file, and in the recovery catalog if you use one.

Some RMAN properties need to be configured prior to backing up the cloud storage location in your account:

  • Setting the retention period for the backups (30 days).
  • Setting up a device type called sbt_tape that uses the library and config files you just installed. Notice that any defined storage chunks in the cloud will have names starting with onPremBackup_.
  • Turning on encryption. This is for data security and mandatory for an on-premise-to-cloud backup scenario.
  • Setting a degree of parallelism so that multiple threads will be backing-up and restoring your datafiles. This is for performance.
  • Setting backup optimization to ON so that RMAN will not do unnecessary transfers to and from the cloud (e.g., if a backup file is already present and has not had any changes before a “new” backup is performed, this file will not be dealt with, saving time).
  • Setting a compression level for the files going to and from the cloud.
  • Configuring the sbt_tape device as the default for all backups.
  • Connect RMAN to local database using:
    RMAN> run {
    
    configure retention policy to recovery window of 30 days;
    
    CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' MAXPIECESIZE 2 G FORMAT 'onPremBackup' PARMS 'SBT_LIBRARY=/u01/app/oracle/product/19c/dbhome_1/lib/libopc.so ENV=(OPC_PFILE=/u01/app/oracle/product/19c/dbhome_1/dbs/opcORCL.ora)';
    
    configure encryption for database on;
    
    configure device type 'sbt_tape' parallelism 1 backup type to backupset;
    
    configure backup optimization on;
    
    configure compression algorithm 'MEDIUM' as of release 'default' optimize for load true;
    
    configure default device type to sbt_tape;
    
    }

Back Up the On-Premises Database

For security reasons, backing up to OCI requires that encryption is used. The options are: transparent data encryption (TDE) or password encryption, or both. We will be using password encryption.

For backup and recovery, run this sequence of commands from a shell script or an RMAN run block.
  1. Set password encryption.
    RMAN> set encryption on identified by ‘password’ only;
  2. Run the backup command.
    RMAN> backup as compressed backupset tag ‘onprem’ database plus archivelog;
  3. Note:

    When creating a backup, the file chunks are placed in a user-defined object storage bucket db_backups in the compartment, or it will use a system-generated container called oracle-data-storage-xxx. We can verify the backup went to the cloud once the backup command has completed.
    Using RMAN, verify the backup files by typing list backup summary.
    RMAN> create restore point gold preserve;
  4. Exit RMAN.

Validate Backups in OCI Cloud

Validate the backups into Oracle Cloud Infrastructure Object Storage. Once validated, you can drop the table to test and then proceed to restore.

  1. Open Oracle Cloud console.
  2. Open Object Storage.
    • From the main menu, click storage, and then Object storage
    • In the search bar, enter "object storage", and press Enter.
  3. From the List Scope, select the compartment.
    This will display the backed-up bucket with either a user-generated name or a system-generated name.
  4. Select the backup bucket to see the file_chunks of the backup set.

Test Restore and Recovery of the Database

Restore the database to the point in time before the database was deleted.

  1. Switch to RMAN session.
    rman target /
  2. Shut down the database.
    RMAN>Shutdown immediate;
  3. Start up mount.
    RMAN>Startup mount
  4. De-encrypt the password.
    RMAN> set decryption identified by ‘Oracle_1’;
  5. Note:

    The following steps will bring the entire database to a point where media recovery can occur. This takes the database offline. If you had multiple PDBs in the database and only needed to recover data in one while leaving the others online, you could use the steps to only close the PDB, restore, and recover the PDB to the restore point. It takes a little longer using this method, so for these instructions we’ll recover the entire database.
    Recover the entire database.
    RMAN> run {
    restore database;
    
    Recover database to restore point gold;
    
    Alter database open reset logs;
    
        }

    Note:

    This backup script can be scheduled to run at a set time on a daily or weekly basis using cronjob to automate the backup process.
  6. Check the database by running a query command on the database.
    This should show the recovered databases.