Lets suppose you have been requested to refresh a TEST/DEV Database and you don’t have access to the source DB, just access to the backups someone created.

In this case, this is a Windows environment and we are going to assume the following information:

DB and Archive log backups located under: “D:\RMAN\Backup\”
Control file backup to use under: “D:\RMAN\Backup\Control\”
DATAFILES on DB to refresh will be located: “D:\ORACLE\ORADATA\ORC\ORC\DATAFILE\”

1:- Start DB in NOMOUNT and restore controlfile:

    RMAN> restore controlfile from 'D:\RMAN\Backup\Control\CF_BACKUP.bck'; 
	
2:- Generate the NEWNAME lines for the RMAN script:

	select 'SET NEWNAME FOR DATAFILE ' ||file#|| ' to ''' ||name|| ''';' 
		from (select file#, name from v$datafile order by 1);	

	*CHANGE the PATH to where we want to leave datafiles (to "D:\ORACLE\ORADATA\ORC\ORC\DATAFILE\")
	
3:- DELETE all the datafiles from Operative System ( from "D:\ORACLE\ORADATA\ORC\ORC\DATAFILE\")
      	*this is to not miss any rogue datafile

4:- Start DB in mount and catalog backups:

	RMAN> alter database mount;
	RMAN> catalog start with 'D:\RMAN\Backup\';

5:- RESTORE DB:

	RMAN> spool log to D:\RMAN\Log\restore_database.log;   <<--- if you want to keep a log
	RMAN> run
	{
	allocate channel C1 type disk;
	allocate channel C2 type disk;
	allocate channel C3 type disk;
	allocate channel C4 type disk;
	allocate channel C5 type disk;
	allocate channel C6 type disk;
	*** HERE teh list of NEWNAME commands from point 2
	restore database;
	switch datafile all;
	release channel C1;
	release channel C2;
	release channel C3;
	release channel C4;
	release channel C5;
	release channel C6;
	}

6:- RECOVER DB: 
	RMAN> spool log to D:\RMAN\Log\recover_database.log;   <<--- if you want to keep a log
	RMAN> recover database;

7: open reset logs:
	alter database open resetlogs;
	
8: Check the database role, recreate temp files if necessary & do health check.
	**temp files might still be pointing to tge PATH/ASM DG from source DB, so recreation might be needed

FINISH!
Last modified: 19 July 2021

Author

Comments

Write a Reply or Comment

Your email address will not be published.