Sunday 17 June 2018

How to Duplicate a database using RMAN backup

Dear DBA-Mates,
Hope you all doing Good!!!
We are back with RMAN database backup and RMAN duplicate database command which we were promised in our last post OracleRMAN Interview Questions and Answers.
Here, simply we are proving the commands for How to take RMAN back and then how to restore as RMAN Duplicate database.
Many of us think how to take rman backup and rman duplicate the database in real scenario because still there are some organizations where RMAN is not
using. But now a day RMAN is very necessary.

RMAN Important Terms:

DEVICE TYPE --> disk or tape or SBT
IMAGE COPIES -- simple copy of databse as cp command in linux
BACKUPSET --> backupsets is a logical entity to backup pieces as a tablespace to data files. Backup pieces are in an RMAN specific binary format.

Note: You cannot perform incremental backups with image copies but you can do so with backup sets.

FORMAT --> to store backup at specific location/speciafic format (date/time).

TAG --> to identify/alias name for backup.

AS COMPRESSED BACKUPSET --> binary( Oracle database files) compression of backupsets, performance overhead during backups and restores.

Steps to take RMAN Backup from database either PROD or STANDBY:
We should use STANDBY because performance will not effect on PROD.

RMAN BACKUP STEPS:
sql "alter session set nls_date_format=''dd.mm.yyyy hh24:mi:ss''";
RUN
{
configure controlfile autobackup on;
set command id to 'DBOnlineBackupFull';
ALLOCATE CHANNEL c1 DEVICE TYPE disk;
ALLOCATE CHANNEL c2 DEVICE TYPE disk;
ALLOCATE CHANNEL c3 DEVICE TYPE disk;
ALLOCATE CHANNEL c4 DEVICE TYPE disk;
ALLOCATE CHANNEL c5 DEVICE TYPE disk;

backup AS COMPRESSED BACKUPSET full database 
tag <backup_name_full
format '< backup location with format>/%d_%T_%s_%p_FULL' ;

backup archivelog all
tag <DB_ARCHIVE>  
format '<location with format>/%d_%T_%s_%p_ARCHIVE' ;

backup current controlfile
tag <DB_CONTROL 
format '<location with format>/%d_%T_%s_%p_CONTROL';

release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;

}

After Backup completed, scp to the Target (Test) server and follow the below steps to DUPLICATE the database.

Now perform the RMAN Duplication as below.
Step 1) Login to Target (Test) database tier and source the Environment
Step 2) connect as sysdba , i.e. sqlplus ‘/as sysdba’
SQL> startup nomount;  ## it should start from spfile.
SQL>exit
$rman log=RMAN_dup_SID_timestamp.log
RMAN> connect auxiliary /
RMAN> run
 {
ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux3 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux4 DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux5 DEVICE TYPE DISK;

DUPLICATE DATABASE TO <DATABASE_NAME> BACKUP LOCATION '/<backup location>/' NOFILENAMECHECK;
}

Whereas:
NOFILENAMECHECK:
Suppose, If we want the duplicate filenames to be the same as the target filenames, and also if our databases are in different hosts, then we should specify the option as NOFILENAMECHECK.
<backup_name_full>
example: proddb_bkp_full
<backup location with formate>/%d_%T_%s_%p_FULL 
example: /rmanbkp/PROD/%d_%T_%s_%p_FULL' ;

You may like some more below:
Regards,
ora-data Team