November 4, 2017
On-premises RMAN backup placed in a storage object on Oracle Cloud Infrastructure.
This article describes how to take a local to your premises backup of an Oracle database and to store it in OCI, formerly known as Oracle Bare Metal Cloud. Depending on your connectivity to the cloud service this could be useful for small to medium size database backups.
At the moment of writing Oracle offers a terabyte of redundant storage for about 26 USD/month.
For bigger databases this solution would not be practical. An option would be to create a standby in the cloud and to backup it locally to the cloud.Thus the only concern would be the redo log generation against your outbound traffic.
Local setup:
OS: Oracle Linux 7
Oracle Database 12c Enterprise Edition Release 12.2 (ASM, the sample schema installed only)
Oracle Cloud Infrastructure command line interface 2.4.10 (configured and ready to use)
Remote cloud setup:
Basically you would need a valid account that have the rights to create object storage.
You can assign the following policy to grant the minimum rights for this task:
Allow group MyBackupGroup to manage buckets in tenancy
Allow group MyBackupGroup to manage objects in tenancy
Create object storage for RMAN backups.
[oracle@myhost ~]$ oci os bucket create -ns gsebmcs00001 --name zRMAN_CDB1 --compartment-id $C
Private key passphrase:
{
“data”:{
“compartment-id”:
“ocid1.compartment.oc1..aaaaaaaa6ad3nog5bxljgfgzqcc7ez43y5xf3uoeenoak6vgtki4sryXXXX”,
“created-by”:
“ocid1.user.oc1..aaaaaaaa5ybvozyzey2cb7qujufojgzif22rzjf3eqwrievtshw7u2iXXXXX”,
“etag”: “63e993a7-d8b3-4833-bcb3-add706e62589”,
“metadata”: {},
“name”:“zRMAN_CDB1”,
“namespace”: “gsebmcs00001”,
“public-access-type”: “NoPublicAccess”,
“time-created”: “2017-10-30T09:47:02.273000+00:00”
},
“etag”: “63e993a7-d8b3-4833-bcb3-add706e62589”
}
To list the storage:
[oracle@myhost ~]$ oci os bucket list -ns gsebmcs00001 --compartment-id $C
Private key passphrase:
{
“data”: [
{
“compartment-id”:
“ocid1.compartment.oc1..aaaaaaaa6ad3nog5bxljgfgzqcc7ez43y5xf3uoeenoak6vgtki4sryXXXXX”,
“created-by”:
“ocid1.user.oc1..aaaaaaaa5ybvozyzey2cb7qujufojgzif22rzjf3eqwrievtshw7u2iXXXXX”,
“etag”: “26b11817-7706-4cba-a087-8c51e822db78”,
“name”: “XXStorage”,
“namespace”: “gsebmcs00001”,
“time-created”: “2017-07-20T20:17:46.085000+00:00”
},
{
“compartment-id”:
“ocid1.compartment.oc1..aaaaaaaa6ad3nog5bxljgfgzqcc7ez43y5xf3uoeenoak6vgtki4sryXXXXX”,
“created-by”:
“ocid1.user.oc1..aaaaaaaa5ybvozyzey2cb7qujufojgzif22rzjf3eqwrievtshw7u2iXXXXX”,
“etag”: “63fb778f-9819-4637-ac57-9cf79470f5e6”,
“name”: “zRMAN_CDB1”,
“namespace”: “gsebmcs00001”,
“time-created”: “2017-10-30T09:47:02.273000+00:00”
}
]
}
Install the backup module.
You can download the module from here. Download it and unzip the jar file in a working directory.Then we have to configure it – which generates the wallet and config file that will point exactly to a particular compartment, container and object storage. It also will download the library for your operating system.
As oracle user with db’s environment that will backed up.If it is a RAC database – make sure this is executed on all nodes or you may consider putting the files on a shared storage like acfs visible to all nodes.
[oracle@myhost ~] mkdir -p /home/oracle/OPC/lib /home/oracle/OPC/wallet
[oracle@myhost ~]$ java -jar opc_install.jar -opcId 'demo.user03' -opcPass 'user_swift_pass'
\
-container zRMAN_CDB1 -walletDir /home/oracle/OPC/wallet -libDir /home/oracle/OPC/lib
-configfile /home/oracle/OPC/config \
-host https://swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/gsebmcs00001
Oracle Database Cloud Backup Module Install Tool, build MAIN_2017-08-16
Backups would be sent to container zRMAN_CDB1.
Oracle Database Cloud Backup Module wallet created in directory /home/oracle/OPC/wallet.
Oracle Database Cloud Backup Module initialization file /home/oracle/OPC/config created.
Downloading Oracle Database Cloud Backup Module Software Library from file opc_linux64.zip
Download complete.
Please note that you need to pass user’s swift password but not the one you use to login in the cloud service. This is because we use SWIFT Storage API endpoint:
https://swiftobjectstorage.us-phoenix-1.oraclecloud.com
If you do not have already swift password: in OCI console, under user’s setting if you are logged in with the same user.Then on the left pane you will see Swift Password
, click on it and press on Generate Password
. If you are not using the same user then go trough Identity tab and follow the same procedure.
You will have only a chance to copy the SWIFT password. Once the creation window is closed you can’t see nor copy it.
Configure RMAN.
The first line is the actual configuration that tells rman to use the cloud library and the configuration to our object storage.
[oracle@myhost ~] rman target /
Recovery Manager: Release 12.2.0.1.0 - Production on Tue Oct 30
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB1 (DBID=932271568)
RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS
'SBT_LIBRARY=/home/oracle/OPC/lib/libopc.so, SBT_PARMS=
(OPC_PFILE=/home/oracle/OPC/config)';
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO SBT_TAPE;
RMAN> CONFIGURE DEVICE TYPE SBT PARALLELISM 1;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO '%F';
RMAN> CONFIGURE COMPRESSION ALGORITHM 'MEDIUM';
Take a backup
rman target /
Recovery Manager: Release 12.2.0.1.0 - Production on Tue Oct 30
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB1 (DBID=932271568)
RMAN> SET ENCRYPTION ON IDENTIFIED BY 'passw0rd' ONLY;
executing command: SET encryption
RMAN> backup database plus archivelog;
Starting backup at 30-OCT-17
current log archived
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=290 instance=cdb11 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Database Backup Service Library VER=3.17.9.5
channel ORA_SBT_TAPE_1: starting archived log backup set
channel ORA_SBT_TAPE_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=4 STAMP=958556529
input archived log thread=2 sequence=1 RECID=1 STAMP=958554607
.....
.....
Starting backup at 30-OCT-17
using channel ORA_SBT_TAPE_1
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=00001 name=+DATA/CDB1/DATAFILE/system.283.958553977
input datafile file number=00003 name=+DATA/CDB1/DATAFILE/sysaux.284.958554033
input datafile file number=00004 name=+DATA/CDB1/DATAFILE/undotbs1.285.958554069
input datafile file number=00009 name=+DATA/CDB1/DATAFILE/undotbs2.298.958554387
input datafile file number=00007 name=+DATA/CDB1/DATAFILE/users.286.958554071
.....
.....
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:01:25
Finished backup at 30-OCT-17
Starting backup at 30-OCT-17
current log archived
using channel ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: starting archived log backup set
channel ORA_SBT_TAPE_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=7 RECID=11 STAMP=958728105
channel ORA_SBT_TAPE_1: starting piece 1 at 30-OCT-17
channel ORA_SBT_TAPE_1: finished piece 1 at 30-OCT-17
piece handle=06sia1t9_1_1 tag=TAG20171030T092145 comment=API Version 2.0,MMS Version
3.17.9.5
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:15
Finished backup at 30-OCT-17
Starting Control File and SPFILE Autobackup at 30-OCT-17
piece handle=c-932271568-20171030-00 comment=API Version 2.0,MMS Version 3.17.9.5
Finished Control File and SPFILE Autobackup at 30-OCT-17
RMAN> list backup of database;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 1.04G SBT_TAPE 00:02:21 30-OCT-17
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20171030T091557
Handle: 03sia1id_1_1 Media: swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/gsebmcs00001/
List of Datafiles in backup set 3
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
1 Full 1934960 30-OCT-17 NO +DATA/CDB1/DATAFILE/system.283.958553977
3 Full 1934960 30-OCT-17 NO +DATA/CDB1/DATAFILE/sysaux.284.958554033
4 Full 1934960 30-OCT-17 NO +DATA/CDB1/DATAFILE/undotbs1.285.958554069
7 Full 1934960 30-OCT-17 NO +DATA/CDB1/DATAFILE/users.286.958554071
9 Full 1934960 30-OCT-17 NO +DATA/CDB1/DATAFILE/undotbs2.298.958554387
....
....
Validate backup
If you try to validate or restore the backup without decryption password it will fail:
RMAN> restore database validate;
Starting restore at 31-OCT-17
using target database control file instead of recovery catalog
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=50 instance=cdb11 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Database Backup Service Library VER=3.17.9.5
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=270 instance=cdb11 device type=DISK
channel ORA_SBT_TAPE_1: starting validation of datafile backup set
channel ORA_SBT_TAPE_1: reading from backup piece 03sia1id_1_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 10/31/2017 06:06:58
ORA-19870: error while restoring backup piece 03sia1id_1_1
ORA-19913: unable to decrypt backup
ORA-28365: wallet is not open
RMAN> set decryption identified by 'passw0rd';
executing command: SET decryption
using target database control file instead of recovery catalog
RMAN> restore database validate;
Starting restore at 31-OCT-17
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=50 instance=cdb11 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Database Backup Service Library VER=3.17.9.5
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=283 instance=cdb11 device type=DISK
channel ORA_SBT_TAPE_1: starting validation of datafile backup set
channel ORA_SBT_TAPE_1: reading from backup piece 03sia1id_1_1
channel ORA_SBT_TAPE_1: piece handle=03sia1id_1_1 tag=TAG20171030T091557
channel ORA_SBT_TAPE_1: restored backup piece 1
channel ORA_SBT_TAPE_1: validation complete, elapsed time: 01:01:57
channel ORA_SBT_TAPE_1: starting validation of datafile backup set
channel ORA_SBT_TAPE_1: reading from backup piece 04sia1nj_1_1
channel ORA_SBT_TAPE_1: piece handle=04sia1nj_1_1 tag=TAG20171030T091557
channel ORA_SBT_TAPE_1: restored backup piece 1
channel ORA_SBT_TAPE_1: validation complete, elapsed time: 00:30:45
channel ORA_SBT_TAPE_1: starting validation of datafile backup set
channel ORA_SBT_TAPE_1: reading from backup piece 05sia1qj_1_1
channel ORA_SBT_TAPE_1: piece handle=05sia1qj_1_1 tag=TAG20171030T091557
channel ORA_SBT_TAPE_1: restored backup piece 1
channel ORA_SBT_TAPE_1: validation complete, elapsed time: 00:26:36
Finished restore at 31-OCT-17
For reference and further details: OCI Storage main page .