Backup of Database In Cloud

In this blog post, I will be discussing  backing up Oracle Database to storage in Oracle Public Cloud mainly around why you will consider such an option and how to setup and run some simple backup and restore operation.

Typically an Oracle database backup using Recovery Manager (RMAN) involves one of the following:

  1. Backup to disk first and then pushed to tape for long term retention.
  2. Directly to tape.
  3. Or use of specialised  hardware such as Zero Data Loss Recovery Appliance (ZDLRA), EMC Data Domain etc.

The first two methods are very common across database estates of all sizes. Use of specialized software or hardware is  useful especially for  very large databases or very demanding RTO.

Backup to cloud promises to replace the local disks and tape in most situations where backup size is reasonable to send across network to cloud and RTO is not very demanding.

I will be using Oracle 12.1.0.2 with latest Patch Set (12.1.0.2.161018), but it is supported for earlier versions as well. As per the support note (DOC ID 1640149.1),  backup of Oracle database to cloud is supported for 10.2.0.5 and above.

One of the primary benefit of Cloud based backup is that you have your backup files always available on database hosts. That is, no need for tape management for old backups. Recovery manager remains the tool and interface for backup to cloud, therefore (potentially) no change in wrapper scripts.

Backup to Oracle Cloud uses https and therefore you do not need to open any port on your firewall. However, proxy settings may be required, which I will discuss below.

Installation

Oracle Database backup to cloud uses Recovery Manager, but needs a new library that allows to add Cloud Storage as SBT target type. Hence a minor installation is required.

  • Download Backup Module from OTN

The installer for backup module is available here.

  • Run installation script

Ensure that the database host is connected to internet, as it will download the latest backup module software library file. You will need JDK 1.7 or higher.

( note the single quote around username and password )

[oracle@oel7 sw]$ java -jar opc_install.jar -serviceName Storage -identityDomain     ********** -opcId ‘*********’ -opcPass ‘*********’ -walletDir /u01/app/oracle/product/12.1.0/dbhome_1/wallet -libDir /u01/app/oracle/product/12.1.0/dbhome_1/lib

Oracle Database Cloud Backup Module Install Tool, build 2016-06-24
Oracle Database Cloud Backup Module credentials are valid.
Oracle Database Cloud Backup Module wallet created in directory /u01/app/oracle/product/12.1.0/dbhome_1/wallet.
Oracle Database Cloud Backup Module initialization file /u01/app/oracle/product/12.1.0/dbhome_1/dbs/opcPOCDB01.ora created.
Downloading Oracle Database Cloud Backup Module Software Library from file opc_linux64.zip.
Downloaded 26528348 bytes in 23 seconds. Transfer rate was 1153406 bytes/second.

  • New files added by installer

The installer will add (or update) three files in the ORACLE_HOME directory. These are

$ORACLE_HOME/dbs/opcPOCDB01.ora
-libDir/libopc.so
-walletDir/cwallet.sso

opcPOCDB01.ora file contains location of Storage Cloud and wallet to retrieve credential to access Storage Cloud container. Optionally, you can specify container name either at install time or by updating this file if you want to segregate backups of  different databases in their own named containers.

OPC_HOST=https://gse00000379.storage.oraclecloud.com/v1/Storage-gse00000379
OPC_WALLET=’LOCATION=file:/u01/app/oracle/product/12.1.0/dbhome_1/wallet CREDENTIAL_ALIAS=alias_opc’

Backup Prerequisites

  • Configure RMAN Environment
Connect to database using RMAN and set Device Type, Encryption and Compression. All backup files to Oracle Cloud needs to be encrypted. Compression is optional but recommended to reduce network traffic.

CONFIGURE CHANNEL DEVICE TYPE set PARMS=’SBT_LIBRARY=/u01/app/oracle/product/12.1.0/dbhome_1/lib/libopc.so,
SBT_PARMS=(OPC_PFILE=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/opcPOCDB01.ora)’;
CONFIGURE ENCRYPTION FOR DATABASE ON;
CONFIGURE COMPRESSION ALGORITHM ‘MEDIUM’;
CONFIGURE DEVICE TYPE sbt BACKUP TYPE TO COMPRESSED BACKUPSET;

  • Proxy Settings if necessary

The Cloud Backup Module installer allows proxy settings for database host to connect to internet. Parameters proxyHost, proxyPort, proxyId and ProxyPass can be used to specify Proxy server name, port, username and password. Alternatively, proxy settings can be enabled using Proxy autoconfiguration URL (usually leads to proxy.pac or wpad.dat on a web server). Web Proxy Auto Discovery details can be found here. And a very good article on how to enable it for Linux can be found here.

  • Encryption Configuration

Backup to Oracle Cloud is always encrypted. The encryption can be achieved using password or software keystore or both. These methods are documented here. In my test, I will be using password for encryption and decryption for backup and restore. Software keystore could be a better approach for a medium to large database estate.

Initiating a Backup

Once the cloud backup module has been installed and Recovery Manager configuration updated as mentioned above, making database backup to Oracle Cloud is straight forward, as it uses the exact same backup (and restore) commands that you would use otherwise. In my test below, I am using password for encryption before initiating backup.

RMAN> set encryption on identified by welcome1 only;
executing command: SET encryption
RMAN> backup database;
Starting backup at 17-DEC-16
using channel ORA_SBT_TAPE_1
using channel ORA_SBT_TAPE_2
using channel ORA_SBT_TAPE_3
using channel ORA_SBT_TAPE_4
channel ORA_SBT_TAPE_1: starting full datafile backup set
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
input datafile file number=00011 name=/u01/app/oracle/oradata/POCDB01/3BC9FE60FA901932E055000000000001/datafile/o1_mf_aco_ts_cx070obo_.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/POCDB01/3BC9FE60FA901932E055000000000001/datafile/o1_mf_system_cwvqbsjw_.dbf
channel ORA_SBT_TAPE_1: starting piece 1 at 17-DEC-16



piece handle=2lrnmrk8_1_1 tag=TAG20161217T125908 comment=API Version 2.0,MMS Version 3.16.9.21
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:09:06
Finished backup at 17-DEC-16
Starting Control File and SPFILE Autobackup at 17-DEC-16
piece handle=c-1598815532-20161217-00 comment=API Version 2.0,MMS Version 3.16.9.21
Finished Control File and SPFILE Autobackup at 17-DEC-16
RMAN>

Restoring from Backup in Cloud

Restoring from a database backup stored in Oracle Cloud is equally straight forward and uses exact same restore commands, except that decryption will be required as backup was encrypted.

RMAN> set decryption identified by welcome1;
executing command: SET decryption
using target database control file instead of recovery catalog
RMAN> restore database;
Starting restore at 17-DEC-16
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=23 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Database Backup Service Library VER=3.16.9.21
allocated channel: ORA_SBT_TAPE_2
channel ORA_SBT_TAPE_2: SID=24 device type=SBT_TAPE
channel ORA_SBT_TAPE_2: Oracle Database Backup Service Library VER=3.16.9.21
allocated channel: ORA_SBT_TAPE_3


channel ORA_SBT_TAPE_3: restoring datafile 00003 to /u01/app/oracle/oradata/POCDB01/datafile/o1_mf_sysaux_cwvpvkbn_.dbf
channel ORA_SBT_TAPE_3: reading from backup piece 2jrnmphc_1_1
channel ORA_SBT_TAPE_4: starting datafile backup set restore
channel ORA_SBT_TAPE_4: specifying datafile(s) to restore from backup set
channel ORA_SBT_TAPE_4: restoring datafile 00004 to /u01/app/oracle/oradata/POCDB01/datafile/o1_mf_undotbs1_cwvpy2nr_.dbf


channel ORA_SBT_TAPE_4: restored backup piece 1
channel ORA_SBT_TAPE_4: restore complete, elapsed time: 00:12:26
Finished restore at 17-DEC-16
RMAN> RECOVER DATABASE;
Starting recover at 17-DEC-16
using channel ORA_SBT_TAPE_1
using channel ORA_SBT_TAPE_2
using channel ORA_SBT_TAPE_3
using channel ORA_SBT_TAPE_4
using channel ORA_DISK_1
starting media recovery


media recovery complete, elapsed time: 00:00:07
Finished recover at 17-DEC-16
RMAN>

Things to remember

  • Recovery Catalog is recommended for ease of restore and recovery. But if you are not using Recovery Catalog, preserve RMAN backup log files.
  • Backup keystore used for encryption key to another location (not Oracle Storage Cloud) as loss of keystore will leave the backups unusable. Similarly, if you prefer to use password for encryption, then preserve it in a password vault.

More information such as monitoring storage consumption, troubleshooting etc. are available in the Oracle Documentation and DOC ID 1640149.1 on support.oracle.com.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s