DUPLICATE TARGET DATABASE TO "TEST" (but we cant use this command, because target is unavailable).
Scenario:
Source: PROD Files: /data01/PROD/oradata
Target: TEST Files: /data01/TEST/oradata
Here is a work around I found (There probably other ways to do this):
a) Temporarily name the target database as source ie PROD.
b) Prepare the init
c) export ORACLE_SID=PROD on the target server.
d) startup nomount
e) rman target / nocatalog
restore controlfile from 'backup_piece';
alter database mount;
catalog backup piece 'backup_piece1';
catalog backup piece 'backup_piece2';
......
catalog backup piece 'backup_piecen';
run {
allocate channel c1 device type DISK;
...
allocate channel cn device type DISK;
set newname for datafile 1 to '/data01/TEST/oradata/system01.dbf'; (We are using the Target datbase name here instead of source, because we would be later renaming the database to TEST, so we want the datafiles to go to the correct location).
set newname for datafile 2 to '/data01/TEST/oradata/ar_index09.dbf';
.....
set newname for datafile n '/data01/TEST/oradata/xxxxxx.dbf';
sql "alter database rename file ''/data01/PROD/redo1_01.log'' to ''/data01/TEST/redo1_01.log'' ";
sql "alter database rename file ''/data01/PROD/redon_0n.log'' to ''/data01/TEST/redon_0n.log'' ";
restore database;
switch datafile all;
recover database;
release channel c1;
...
release channel cn;
}
f) Once the database is up and open. Rename the database by recreating the controlfile.