This is the first of a multi-part blog series walking through how to copy your TDE encrypted on premise Oracle Database to an OCI VM in the oracle cloud using the Oracle Database Backup Cloud Service.
I am going to start with a simple test case of a small database which doesn't contain any TDE encryption or wallet, and back it up to an OCI bucket.
As far as where to start, below are some documentation links that will help.
Install Database backup module
The first thing I am going to do is unzip the Cloud Backup Module (opc_installer.zip). This can downloaded using the link above, but it can also be found within the $ORACLE_HOME/lib directory. As always, I would recommend downloading the current copy to be sure it is the latest release. Once unzipped you will find the module contains a directory "opc_installer". Within "opc_installer" there are 2 subdirectories with a ".jar" file to install the library, and a readme file.
oci_install.jar
I am going to use "oci_install.jar" file and access the bucket using the Oracle Cloud Native API.
If I look in the "readme" file, I can see that I install the library using the following parameters.
I am going to install my files within a new directory for my Database host.
wallet/
To install and configure my library I am going to execute
-host https://objectstorage.us-ashburn-1.oraclecloud.com
-pvtkeyFile /home/oracle/ocicloud/myprivatekey.ppk
-pubFingerPrint 6d:f9:57:d5:ff:b1:c0:98:81:90:1e:6e:08:0f:d0:69
-tOCID ocid1.tenancy.oc1..aaaxxxnoq
-uOCID ocid1.user.oc1..aaaaaaaae2mlwyke4gvxxsaouxq
-bucket migest_backups
-walletDir /home/oracle/ocicloud/wallet
-configFile /home/oracle/ocicloud/config/migtestbackup.ora
-cOCID ocid1.compartment.oc1..aaaaaaaanqbquh2bwju4igzd3tyq
-libDir /home/oracle/ocicloud/lib
Oracle Database Cloud Backup Module Install Tool, build MAIN_2021-08-31Oracle Database Cloud Backup Module credentials are valid.Backups would be sent to bucket migest_backups.Oracle Database Cloud Backup Module wallet created in directory /home/oracle/ocicloud/wallet.Oracle Database Cloud Backup Module initialization file /home/oracle/ocicloud/config/migtestbackup.ora created.Downloading Oracle Database Cloud Backup Module Software Library from Oracle Cloud Infrastructure.Download complete.
Now that it is successfully installed we can go to configuring the module.
Configure Database backup module
find . | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
.
|-lib
| |-bulkimport.pl
| |-libopc.so
| |-metadata.xml
| |-odbsrmt.py
| |-perl_readme.txt
| |-python_readme.txt
|-config
| |-migtestbackup.ora
|-wallet
| |-cwallet.sso.lck
| |-cwallet.sso
|-oci_install.jar
|-myprivatekey.ppk
OPC_HOST=https://objectstorage.us-ashburn-1.oraclecloud.com/n/id20avsofo
OPC_WALLET='LOCATION=file:/home/oracle/ocicloud/wallet CREDENTIAL_ALIAS=alias_oci'
OPC_CONTAINER=migest_backups
OPC_COMPARTMENT_ID=ocid1.compartment.oc1..aaaaaaaanqbquh2bwju4igabu5g7xuiijael2fwcpqyvzzb4ykd3tyq
OPC_AUTH_SCHEME=BMC
## Default device type is tape
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
## Backup using the library and config file we just installed
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/home/oracle/ocicloud/lib/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/ocicloud/config/migtestbackup.ora)';
## Backup with 4 channels to a compressed backupset
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 4 BACKUP TYPE TO COMPRESSED BACKUPSET;
## Use medium compression since this is included in the license for the module.
CONFIGURE COMPRESSION ALGORITHM 'MEDIUM';
## Encrypt the backup being sent, this is mandatory for writing to the cloud.
CONFIGURE ENCRYPTION FOR DATABASE ON;
Backup Database to an OCI bucket
set encryption identified by oracle only;
backup incremental level 0 database plus archivelog not backed up;
Configure Database backup module in OCI.
Oracle Database Cloud Backup Module Install Tool, build MAIN_2021-08-31
Oracle Database Cloud Backup Module credentials are valid.
Backups would be sent to bucket migest_backups.
Oracle Database Cloud Backup Module wallet created in directory /home/oracle/ocicloud/wallet.
Oracle Database Cloud Backup Module initialization file /home/oracle/ocicloud/config/migtestbackup.ora created.
Downloading Oracle Database Cloud Backup Module Software Library from Oracle Cloud Infrastructure.
Download complete.
Configure pfile for database in OCI.
audit_file_dest='/u01/app/oracle/admin/migtest/adump'
*.audit_trail='db'
*.compatible='19.0.0'
*.control_files='/u01/app/oracle/oradata/MIGTEST/controlfile/controlfile1.ctl','/u01/app/oracle/oradata/MIGTEST/controlfile/controlfile2.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata'
*.db_name='migtest'
*.processes=300
*.sga_target=4638m
Restore pfile and controlfile for database in OCI
- I add my database to the "/etc/oratab" to ensure I can connect to it, and ". oraenv" to set the environment.
- I now start up the database nomount
- I go back to the original database to retrieve the dbid.
set decryption identified by oracle;
run {
allocate CHANNEL c1 TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/home/oracle/ocicloud/ib/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/ocicloud/config/migtestbackup.or)';
restore spfile from autobackup ;
release channel c1;
}
rman target /
RMAN> set decryption identified by oracle;
executing command: SET decryption
run {
allocate CHANNEL c1 TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/home/oracle/ocicloud/ib/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/ocicloud/config/migtestbackup.or)';
restore spfile from autobackup ;
release channel c1;
}
RMAN> 2> 3> 4> 5>
allocated channel: c1
channel c1: SID=20 device type=SBT_TAPE
channel c1: Oracle Database Backup Service Library VER=21.0.0.1
Starting restore at 20-DEC-21
channel c1: looking for AUTOBACKUP on day: 20211220
channel c1: AUTOBACKUP found: c-286701374-20211220-00
channel c1: restoring spfile from AUTOBACKUP c-286701374-20211220-00
channel c1: SPFILE restore from AUTOBACKUP complete
Finished restore at 20-DEC-21
set decryption identified by oracle;
run {
allocate CHANNEL c1 TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/home/oracle/ocicloud/ib/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/ocicloud/config/migtestbackup.or)';
restore controlfile from autobackup ;
release channel c1;
}
RMAN>
executing command: SET decryption
using target database control file instead of recovery catalog
RMAN> 2> 3> 4> 5>
allocated channel: c1
channel c1: SID=17 device type=SBT_TAPE
channel c1: Oracle Database Backup Service Library VER=21.0.0.1
Starting restore at 20-DEC-21
channel c1: looking for AUTOBACKUP on day: 20211220
channel c1: AUTOBACKUP found: c-286701374-20211220-00
channel c1: restoring control file from AUTOBACKUP c-286701374-20211220-00
channel c1: control file restore from AUTOBACKUP complete
output file name=/u01/app/oracle/oradata/MIGTEST/controlfile/controlfile1.ctl
output file name=/u01/app/oracle/oradata/MIGTEST/controlfile/controlfile2.ctl
Finished restore at 20-DEC-21
released channel: c1
Restore the datafile for the database in OCI
set linesize 160
set pagesize 0
SELECT REPLACE(file_name,'/home/oracle/app/oracle/oradata/','/u01/app/oracle/oradata/') "Changes"
FROM (select
'set newname for datafile ' || file# || ' to ' || '''' || name || '''' || ';' file_name
from v$datafile
)
;
## Default device type is tape
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
## Backup using the library and config file we just installed
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=/home/oracle/ocicloud/lib/libopc.so,SBT_PARMS=(OPC_PFILE=/home/oracle/ocicloud/config/migtestbackup.ora)';
## Backup with 4 channels to a compressed backupset
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 4 BACKUP TYPE TO COMPRESSED BACKUPSET;
## Use medium compression since this is included in the license for the module.
CONFIGURE COMPRESSION ALGORITHM 'MEDIUM';
## Encrypt the backup being sent, this is mandatory for writing to the cloud.
CONFIGURE ENCRYPTION FOR DATABASE ON;
run {
restore database;
recovery database;
switch datafile all;
}
RMAN> alter database open resetlogs;
Statement processed
RMAN>
That's all there is to it.