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

11 comments:

  1. Excellent Article ...thank u for sharing, such a valuable content Learners to get good knowledge after read this article..Oracle R12 Financials Training in Ameerpet

    ReplyDelete
  2. 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.

    Regards,
    ora-data Team

    ReplyDelete
  3. Hi there, You have done an excellent job. I'll definitely digg it and personally suggest
    to my friends. I'm confident they will be benefited from this website.

    ReplyDelete
    Replies
    1. Dear User,
      Thank you for your feedback and sharing.
      Sure, it will be helpful because we share only real time scenario...

      Regards,
      ora-data Team

      Delete
  4. Right here is the right website for anybody who hopes to find out about this topic.
    You understand so much its almost hard to argue with you
    (not that I personally will need to...HaHa).
    You certainly put a brand new spin on a topic that's been written about for ages.
    Great stuff, just great!

    ReplyDelete
  5. Dear User,
    Thank you for your valuable feedback.
    We will keep it same quality...

    Regards,
    ora-data Team

    ReplyDelete
  6. Hi My friend.
    If i am using ASM... means i need to restore datafiles and SP file in ASM location the above duplicate will work ..?

    ReplyDelete
    Replies

    1. Dear Ganga,

      Hope this may useful for you:
      https://web.stanford.edu/dept/itss/docs/oracle/10gR2/backup.102/b14191/rcmdupdb006.htm

      Regards,

      Delete
  7. For this is it a must to delete Data & control files from target?

    ReplyDelete
    Replies

    1. Hi Soumya,

      We use to delete the files.
      If you don't delete controlfile it may give error as control files already exists.

      Regards,
      ora-data Team

      Delete
  8. In fact no matter if someone doesn't be aware of after
    that its up to other people that they will help, so here it happens.

    ReplyDelete

Thank you for your comments and suggestions. It's good to talk you.