Oracle restore to a differnet drive I have the following script for rman to backup the main database and archive logs:

connect target sysdba/password@localhost/db
run
{
allocate channel d1 type disk;
crosscheck archivelog all;
delete noprompt expired archivelog all;
crosscheck backup;
delete noprompt expired backup;
backup AS COMPRESSED BACKUPSET tag Full_database_open format 'E:\backup\data\db_%Y_%M_%D_%t_%s_p%p.dbf' database;
sql 'alter system archive log current';
sql 'alter system archive log current';
backup AS COMPRESSED BACKUPSET archivelog all format 'E:\backup\data\al_%Y_%M_%D_%t_%s_p%p.dbf' delete all input;
delete noprompt obsolete redundancy = 1;
backup AS COMPRESSED BACKUPSET current controlfile tag =cf1 format 'E:\backup\data\cf_%Y_%M_%D_%t_%s_p%p.dbf';
crosscheck archivelog all;
delete noprompt expired archivelog all;
crosscheck backup;
delete noprompt expired backup;
}


The data files are in: E:\APP\ADMINISTRATOR\ORADATA\DB\

I am trying to setup a test server, but installed oracle in the C:\ drive.
How, so the data file is: C:\app\administrator\oradata\DB

I tried the following:

-- sqlplus 
shutdown abort;
startup nomount;

-- rman
restore controlfile from "C:\backup\data\CF_2019_08_27_1017362393_20_P1.DBF";

-- sqlplus
alter database mount;

-- rman
restore database;


unfortunately the backup tries to write data to the E:\ drive which is not present in the test server.

How can I make oracle restore the files to: C:\app\administrator\oradata\DB ?
run
{
  set newname for database to 'C:\app\administrator\oradata\DB\%U';
  restore database;
}
switch database to copy;


This will generate filenames in the specified directory. If you want nice looking names following your naming convention, specify them manually, example:

run
{
  set newname for datafile 1 to 'C:\app\administrator\oradata\DB\system01.dbf';
  set newname for datafile 2 to 'C:\app\administrator\oradata\DB\sysaux01.dbf';  
  ..
  restore database;
}
switch database to copy;


SET