In plain english for a someone whose DBA role is a third or seventh hat, and rarely has to touch Oracle, how do I use RMAN to create a test database from a full recovery backup dataset?
I've kept my whining at the end of the question …
Scenario:
I have a complete RMAN backup set of a production database, taken as a copy of the flash recovery directory, from which I want to build a test database.
I have started to glean an understanding of what I need to do from this post: Oracle 11 rman db restore file corruption.
What I'm not getting is where some of the "alphabet soup" in his example script comes from.
Example script (with annotations):
rman target /
set DBID ... // Where does this come from? The existind DB I plan to overlay, or some magic spot in the RMAN backup set?
startup nomount
RESTORE CONTROLFILE FROM 'file destination' // is this my flash recovery directory?
shutdown;
startup mount;
// Is it right to assume that this is the directory containing the backup?
// Or should I list every single backup file from the flash recovery area (ugh!)?
catalog backuppiece 'C:/BKUP/AL_2851492942_20151016_893271615_PGQJSFHV_1_1';
rman:crosscheck backup; Run{
SET UNTIL SEQUENCE 50511; // Where did this number come from? Is it important? Can I ignore this line since I have a complete recovery set?
RESTORE DATABASE;
SWITCH DATAFILE ALL;
RECOVER DATABASE;
}
sqlplus sys/sys as sysdba
shutdown immediate; startup mount;
alter database noarchivelog; // I see this is considered a bad practice elsewhere??
ALTER DATABASE OPEN;
ALTER TABLESPACE mytempspace // what's this line about? I just want to take a clone of the DB that was backed up elsewhere
ADD TEMPFILE 'c:\oracle............dbf' SIZE 1G REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
Whining:
I know that this is yet another noob question, and some of you experienced oracle DBA's will be rolling your eyes and thinking "RTFM". Unfortunately, the ease of management of SQL server is changing industry expectations, and anyone who can use a mouse is expected to be an instant DBA. That works with SQLServer, but not with Oracle.
In SQL server this is a simple task that comes down to pick your source backupset, pick your target database, click on the "replace database from backup", click "go", and then go for coffee.
In Oracle with rman, it looks like it should also be a simple task, but all the documents I have found appear to assume that the oracle DBA role is filled by a full time specialist in oracle who just needs a nudge in the right direction. While Tom Kite is really good, his page on this exact problem spends a lot of time babbling about transportable spaces and such, and quickly becomes indecipherable because of the assumptions of the depth of knowledge of the reader.
Best Answer
First place to check is Oracle official documentation. For example http://docs.oracle.com/cd/E36909_01/backup.1111/e10642/rcmdupdb.htm#autoId0 Depending of your database version(10g, 11g, 12c...). Just search documentation for duplicate database. I am not going to explain all questions from your script because it could only confuse you a little more.
Depending of prod db size you could use datapump export and import for example, or transportable tablespaces or like you tried RMAN. Your rman commands should be something like
When the databases are of different versions, use expdp/impdp:
This script can be written in many ways, depending if you want to recover to specific date and time, specific SCN, is test db the same structure(the same path for data and other files) or not, the same operating system or not, do you need to change some initialization parameters or not etc.