Sunday, July 13, 2008

Refreshing Database

1) Backup up source database

rman target sys/manager nocatalog

run
{
allocate channel c1 type disk;
backup database format '\backup\db1_%U.bck';
release channel c1;
}


2) Backup control file on source database

ALTER DATABASE BACKUP CONTROLFILE TO '/backup/control.bck';


3) Copy all required archived logs and backup files along with control file backup to target database archive and backup directory respectively.

4) Shutdown target database

5) Copy backup control file to target control file location specified in parameter file

6) Change the db_name and archive log format of target database parameter file similar to source.

7) Startup mount target database

8) Connect to RMAN on target database and restore database (Use set newname to specify new file system path)

rman target sys/manager nocatalog

run
{
allocate channel c1 type disk;
set newname for datafile 1 to '/oradata/db2/SYSTEM01.DBF';
set newname for datafile 2 to '/oradata/db2/UNDOTBS01.DBF';
set newname for datafile 3 to '/oradata/db2/SYSAUX01.DBF';
set newname for datafile 4 to '/oradata/db2/USERS01.DBF';
set newname for datafile 5 to '/oradata/db2/EXAMPLE01.DBF';
set newname for datafile 6 to '/oradata/db2/STRMTAB_01.DBF';
set newname for datafile 7 to '/oradata/db2/LOGMNRTST_01.DBF';
restore database;
switch datafile all;
release channel c1;
}

9) Recover database

recover database using backup controlfile until cancel;

10) Take control file trace of target database

alter database backup controlfile to trace;

11) Edit the trace control file which is in udump directory with target database name and set database option

12) Revert back the parameter of target database with old dbname and archive log format

13) Shutdown immediate target database

14) Start nomount target database

15) Recreate the control file which has been edited in step 11

16) Open database with resetlogs option

alter database open resetlogs;

17) Add tempfile with reuse option and rename global database name

No comments: