Skip to main content
Database Security

How to Backup the Wallet keys from On-premises to Oracle Cloud Storage

By February 27, 2022August 29th, 2022No Comments2 min read

The oracle wallet keys are very important, and there is no way to recover the wallet key lost. To secure them, we must trust on 2nd layer or storage other than the local storage.

The below script helps to identify the wallet files, and also it copies to the OCI swift storage using the curl command. I hope the below script helps to secure your encryption keys.

[oracle@ORA-X1 ~]$ cat /home/oracle/dba/KEYSTORES/SCRIPTS/backup_KEYSTORE.sh

#!/bin/bash

if [ $# -ne 1 ]

then

        echo "usage : backup_KEYSTORE.sh ORACLE_SID"

        exit 1

fi

 ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1

export ORACLE_HOME

ORACLE_SID=$1

#export ORACLE_SID=PRDS

ROOT_FILE=/home/oracle/dba/KEYSTORES

LOG_DIR=${ROOT_FILE}/LOGS

CMD_DIR=${ROOT_FILE}/SCRIPTS

PASSWD_ADMIN=`cat ${CMD_DIR}/admin.pwd | openssl enc -aes-256-cbc -md sha512 -d -pass pass:Welcome123`

export PASSWD_ADMIN

BUCKET_CNX_STRING=`cat ${CMD_DIR}/partnerrermanservice.pwd | openssl enc -aes-256-cbc -md sha512 -d -pass pass:Welcome123`

export BUCKET_CNX_STRING

export TARGET_TMP_LOCATION=/tmp

 ###########################################################################################

#       BACKUP CURRENT KEYSTORE

###########################################################################################

cd ${CMD_DIR}

${ORACLE_HOME}/bin/sqlplus / as sysdba <<EOF

@backup_keystores.sql ${PASSWD_ADMIN} ${TARGET_TMP_LOCATION}

exit

EOF

###########################################################################################

#       COPY BACKUP TO KEYSTORES BUCKET

###########################################################################################

KEYSTORE_BCK_FILE=`ls -rtl ${TARGET_TMP_LOCATION}/ewallet*.p12| tail -1 | awk '{print $9}'|cut -d'/' -f 3`

export KEYSTORE_BCK_FILE

echo $KEYSTORE_BCK_FILE                         

curl -v -X PUT -u ${BUCKET_CNX_STRING} --upload-file ${TARGET_TMP_LOCATION}/${KEYSTORE_BCK_FILE} https://swiftobjectstorage.us-ashburn-1.oraclecloud.com/v1/…./….//${ORACLE_SID}/${KEYSTORE_BCK_FILE}

Leave a Reply