Backup and Restore Oracle Databases using Oracle Database Backup Cloud Service

Oracle Database Cloud Service is been around for sometime now and its shaping out to be a true enterprise cloud backup service for oracle databases. It is a secure, scalable, on-demand storage solution for backing up Oracle databases to Oracle Cloud. Purpose of this blog to show you how
to use Oracle Database Cloud Service to backup or restore your Oracle databases. This blog will only cover backup and restore process and I am assuming that you have install Oracle Cloud Backup Module for Database backup service. if not please use following blog to configure Oracle Cloud Backup Module (http://blog.umairmansoob.com/configure-oracle-database-backup-cloud-service/).

Note : – Make sure to enable auto control backup on and save DBID, you will need them to restore databases. You will also need to provide password to encrypt backups, you will also need same password to restore that database.   

Let starts doing a full backup of a test database then we can drop target databases complete to test our restore process.

Perform FULL Database Backup with AUTO Control file backup enable 

SET ENCRYPTION ON IDENTIFIED BY passw0rd ONLY;
configure compression algorithm 'MEDIUM';
CONFIGURE CONTROLFILE AUTOBACKUP ON;
run
{
allocate channel ch1 device type sbt parms='SBT_LIBRARY=/u01/app/oracle/OPC/lib/libopc.so,ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/db_1/dbs/opctestdb1.ora)';
BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG;
release channel ch1;
}

Let delete target database  using DBCA, so we can test our restore process. 

Now we can start restore database process , as i mentioned it earlier you will need password and DBID to restore database from Database Backup service.

Startup database instance in nomount mode 

RMAN> startup nomount force
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/12.1.0/db_1/dbs/inittestdb1.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area 1073741824 bytes
Fixed Size 2932632 bytes
Variable Size 281018472 bytes
Database Buffers 784334848 bytes
Redo Buffers 5455872 bytes

Set DBID and password to start restore process.

RMAN> set dbid 687787463;
executing command: SET DBID
RMAN> set decryption identified by passw0rd;
executing command: SET decryption

Restore spfile from backup 

RUN {
allocate channel ch1 device type sbt parms='SBT_LIBRARY=/u01/app/oracle/product/12.1.0/db_1/opc/lib/libopc.so,ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/db_1/dbs/opctestdb1.ora)';
RESTORE SPFILE FROM AUTOBACKUP; 
}

Create audit dump directory and startup instance in nomount mode

mkdir -p /u01/app/oracle/admin/testdb1/adump
RMAN> shutdown 
RMAN> startup nomount

Restore Control file from AUTOBACKUP and mount database 

 RUN {
allocate channel ch1 device type sbt parms='SBT_LIBRARY=/u01/app/oracle/OPC/lib/libopc.so,ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/db_1/dbs/opctestdb1.ora)';
RESTORE CONTROLFILE FROM AUTOBACKUP; 
Alter database mount;
}

Restore and Recover Database 

RUN {
allocate channel ch1 device type sbt parms='SBT_LIBRARY=/u01/app/oracle/OPC/lib/libopc.so,ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/db_1/dbs/opctestdb1.ora)';
restore database;
recover database;
}

Open Database using resetlogs 

RMAN> alter database open resetlogs;
Statement processed

 

Delete Backups from Oracle Database Backup Cloud Service

There will be times when you like to delete old backups from Oracle Database cloud Service. This is a very simple task , but since we don’t have much visibility inside backup storage , we need to use Oracle RMAN backup utility to purge any backups. There is option to delete files on Oracle Cloud Storage Container holding backups from cloud management console but as of now you cannot map any files to RMAN backup pieces. May be that is something Oracle will change and provide more visibility to Oracle Database Backup Storage through Cloud management console. For now you can use following steps to delete backups from Oracle Database Cloud Storage.
Step 1 : list backup and find backups pieces you want to delete

RMAN> list backup;

List of Backup Sets
===================
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
1 6.00M SBT_TAPE 00:00:11 11-FEB-17
 BP Key: 1 Status: AVAILABLE Compressed: YES Tag: TAG20170211T125618
 Handle: 01rsaebi_1_1 Media: a430291.storage.oraclecloud.com/v1/Storage-a430291/ORABACKUP

 List of Archived Logs in backup set 1
 Thrd Seq Low SCN Low Time Next SCN Next Time
 ---- ------- ---------- --------- ---------- ---------
 1 6 1600408 11-FEB-17 1605173 11-FEB-17

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 328.00M SBT_TAPE 00:01:32 11-FEB-17
 BP Key: 2 Status: AVAILABLE Compressed: YES Tag: TAG20170211T125643
 Handle: 02rsaecb_1_1 Media: a430291.storage.oraclecloud.com/v1/Storage-a430291/ORABACKUP

....................................................................................................................................................................................................................
.
RMAN>

Step 2 : Configure Backup Channel to Oracle Database Backup Service 

RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/u01/app/oracle/OPC/lib/libopc.so,ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/db_1/dbs/opctestdb1.ora)';

new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/u01/app/oracle/OPC/lib/libopc.so,ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/db_1/dbs/opctestdb1.ora)';
new RMAN configuration parameters are successfully stored
released channel: ORA_DISK_1

Step 3 : Delete select backup pieces to all backups 

RMAN> delete backup;

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=57 device type=DISK
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=36 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Database Backup Service Library VER=3.16.9.21

List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
1 1 1 1 AVAILABLE SBT_TAPE 01rsaebi_1_1
2 2 1 1 AVAILABLE SBT_TAPE 02rsaecb_1_1
3 3 1 1 AVAILABLE SBT_TAPE 03rsaegs_1_1
4 4 1 1 AVAILABLE SBT_TAPE 04rsaej7_1_1
5 5 1 1 AVAILABLE SBT_TAPE 05rsael9_1_1

Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=01rsaebi_1_1 RECID=1 STAMP=935672178
deleted backup piece
backup piece handle=02rsaecb_1_1 RECID=2 STAMP=935672204
deleted backup piece
backup piece handle=03rsaegs_1_1 RECID=3 STAMP=935672348
deleted backup piece
backup piece handle=04rsaej7_1_1 RECID=4 STAMP=935672423
deleted backup piece
backup piece handle=05rsael9_1_1 RECID=5 STAMP=935672489
Deleted 5 objects

 

Configure Oracle Database Backup Cloud Service

Oracle started offering Oracle Database Backup Cloud Service for some time now and I believe it’s time for cloud customers to realize that Oracle will be leading cloud provider in coming months. Oracle Database Backup Cloud Service not only provide secure, scalable, on-demand storage solution for backing up Oracle databases to Oracle Cloud but also complements your existing backup strategy by providing an off-site storage location in the public cloud. Oracle Database Backup Cloud Service is highly available backup service which also support RMAN backup encryption and RMAN backup compression. Here are steps to configure and backup your database to Oracle Database Backup Cloud.

First you need to install oracle backup module. You can download backup module using following link

(http://www.oracle.com/technetwork/database/availability/oracle-cloud-backup-2162729.html ), once download and extract module to any directory.  I will be using $ORACLE_HOME/opc directory to install Oracle backup module. Before you can install the module, you should acquire following information.

  1. identityDomain
  2. Cloud User Name
  3. Cloud User Password
  4. Cloud Storage Rest Point

Please change highlighted items based on your environment

$ java -jar opc_install.jar -serviceName storagesvc -identityDomain <identitydomain> -opcId <USERNAME> -opcPass <password> -walletDir /u01/app/oracle/OPC/wallet -libDir /u01/app/oracle/OPC/lib -host <cloud Storage Rest Point>

Oracle Database Cloud Backup Module Install Tool, build 2016-10-07
Oracle Database Cloud Backup Module credentials are valid.
Oracle Database Cloud Backup Module wallet created in directory /u01/app/oracle/product/12.1.0/db_1/opc/wallet.
Oracle Database Cloud Backup Module initialization file /u01/app/oracle/product/12.1.0/db_1/dbs/opctestdb12c1.ora created.
Downloading Oracle Database Cloud Backup Module Software Library from file opc_linux64.zip.
Downloaded 26528348 bytes in 10 seconds. Transfer rate was 2652834 bytes/second.
Download complete.

Verify install by checking $ORACLE_HOME/dbs and /u01/app/oracle/OPC/wallet directories and see if opcSID.ora and cwallet.sso have been created respectively. If you were able to find above mentioned files, you can start running backups to Oracle database backup cloud service. Here is the simple script to test to newly configure backup service. Please note that Oracle Database Backup cloud Service only support encrypted backups for security reasons and you have option to use TDE or RMAN encryption. I will be using RMAN encryption option for this blog which also don’t require any licensing.

Lets set encryption on before we run any backups

[oracle@oraclenode1 ~]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Sat Feb 11 01:35:36 2017
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.connected to target database: TESTDB12 (DBID=2927258729)

RMAN> SET ENCRYPTION ON IDENTIFIED BY passw0rd ONLY;

executing command: SET encryption
using target database control file instead of recovery catalog

Now lets run try datafile backup to Oracle Database Backup Cloud Service

RMAN> run
{
allocate channel ch1 device type sbt parms='SBT_LIBRARY=/u01/app/oracle/OPC/lib/libopc.so,ENV=(OPC_PFILE=/u01/app/oracle/product/12.1.0/db_1/dbs/opctestdb12c1.ora)';
BACKUP datafile 1;
release channel ch1;
}2> 3> 4> 5> 6>

allocated channel: ch1
channel ch1: SID=71 device type=SBT_TAPE
channel ch1: Oracle Database Backup Service Library VER=3.16.9.21

Starting backup at 11-FEB-17
channel ch1: starting full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata/TESTDB12C1/datafile/o1_mf_system_d9s6oxr3_.dbf
channel ch1: starting piece 1 at 11-FEB-17
Finished backup at 11-FEB-17