Home » Backup and restore example with password encryption in Oracle

Backup and restore example with password encryption in Oracle

by tuanlp

 Following are the things for running the RMAN Backup with Password Protected:

  1. Set the configuration of RMAN to use Encryption:
-- Check the configuration
RMAN> Show all;
-- Set the Configuration to ON value for using encryption password
RMAN> CONFIGURE ENCRYPTION FOR DATABASE ON;
old RMAN configuration parameters:
CONFIGURE ENCRYPTION FOR DATABASE OFF;
new RMAN configuration parameters:
CONFIGURE ENCRYPTION FOR DATABASE ON;
new RMAN configuration parameters are successfully stored
  1. Set the Password before executing RMAN backup.

I set the password as “PASSWORD1” value in the below example.

-- Set the Encryption
RMAN> set encryption on identified by password1 only;
executing command: SET encryption
  1. Run the backup of the database.
run {
allocate channel ch00 type disk;
backup format 'C:\rman\full_db_%t_%sp%p' filesperset 10 database;
release channel ch00;
allocate channel ch00 type disk;
backup format 'C:\rman\cntrl_%s_%p_%t' CURRENT CONTROLFILE;
backup format 'C:\rman\spfile_%s_%p_%t' spfile;
release channel ch00;
}

allocated channel: ch00
channel ch00: SID=397 device type=DISK
Starting backup at 16-SEP-20
channel ch00: starting full datafile backup set
channel ch00: specifying datafile(s) in backup set
input datafile file number=00001 name=C:\ORACLE\ORADATA\XE\SYSTEM01.DBF
input datafile file number=00003 name=C:\ORACLE\ORADATA\XE\SYSAUX01.DBF
input datafile file number=00004 name=C:\ORACLE\ORADATA\XE\UNDOTBS01.DBF
input datafile file number=00007 name=C:\ORACLE\ORADATA\XE\USERS01.DBF
channel ch00: starting piece 1 at 16-SEP-20
channel ch00: finished piece 1 at 16-SEP-20
piece handle=C:\RMAN\FULL_DB_1051289628_67P1 tag=TAG20200916T165139 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:25
Finished backup at 16-SEP-20
Starting Control File and SPFILE Autobackup at 16-SEP-20
piece handle=C:\ORACLE\DBHOMEXE\DATABASE\C-2901846628-20200916-03 comment=NONE
Finished Control File and SPFILE Autobackup at 16-SEP-20
released channel: ch00

Steps of Restore RMAN backup with Password

  1. Set the Decryption password for the database.

Note: Password should be same as you set during taking password. In My Case its value is “PASSWORD1”

RMAN> set decryption identified by password1;
executing command: SET decryption
  1. Run the Restore command:
-- Open database in nomount and restore control file
RMAN> restore controlfile from 'C:\ORACLE\DBHOMEXE\DATABASE\C-2901846628-20200916-03';

Starting restore at 16-SEP-20
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=C:\ORACLE\ORADATA\XE\CONTROL01.CTL
output file name=C:\ORACLE\ORADATA\XE\CONTROL02.CTL
Finished restore at 16-SEP-20

Error without using decryption of Password during restore

RMAN> restore controlfile from 'C:\ORACLE\DBHOMEXE\DATABASE\C-2901846628-20200916-03';

Starting restore at 16-SEP-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=297 device type=DISK
channel ORA_DISK_1: restoring control file
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 09/16/2020 17:04:30
ORA-19870: error while restoring backup piece C:\ORACLE\DBHOMEXE\DATABASE\C-2901846628-20200916-03
ORA-19913: unable to decrypt backup
ORA-28365: wallet is not open

You may also like