How to Restore RMAN Backups on a Different server When the Directory Structures Are Different (Windows operating system)
Source server
Pre request on source database:
• Source server should run on archive log mode.
• Following configuration should enable in RMAN
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
• Target server oracle binary should be installed
1) Backup the database with archive logs
RMAN> backup database plus archivelog;
Copy all the backup pieces to target server, which should include the following backup pieces
• Backup of Datafiles
• Backup of archivelogs
• Backup of SPFILE and CONTROL files
Target server
1) Create dummy instance ,which would be the target database SID
CMD >oradim -new -sid totanew
CMD >set oracle_sid=totanew
NOTE: totanew is new target database SID
2) Connect to the RMA and restore the SPFILE from backup
CMD>rman target /
RMAN>startup nomount
This would start dummy instance call totanew
RMAN> RESTORE SPFILE TO PFILE 'C:\app\oracle\product\11.2.0\dbhome_1\database\inittotanew.ora' FROM 'E:\indika\backup\O1_MF_S_828200600_9552B1J6_.BKP';
NOTE: E:\indika\backup path contains the source database backups
NOTE: inittotanew.ora file name convention is init<NEW SID>.ora
RMAN>startup force nomount;
3) Next, edit the restored PFILE called inittotanew.ora.
Create the necessary directories in the target server
*.audit_file_dest='C:\app\oracle\admin\totanew\adump'
*.control_files='C:\app\oracle\oradata\totanew\control01.ctl',
'C:\app\oracle\flash_recovery_area\totanew\control02.ctl'
*.db_recovery_file_dest='C:\app\oracle\flash_recovery_area'
NOTE: Sometime in windows it’s required to close command prompt and start new one in order to
Save the changes to new INITtotanew.ora. File
RMAN>shutdown immediate
Next restart the instance with modified PFILE
RMAN >startup nomount pfile=’C:\app\oracle\product\11.2.0\dbhome_1\database\INITtotanew.ORA’
4) Restore control file from backup
Connect to the RMA
RMAN >restore controlfile from 'E:\indika\backup\O1_MF_S_828200600_9552B1J6_.BKP';
RMAN >alter database mount
NOTE: E:\indika\backup path contains the source database backups
5) Register the backup pieces in to target database ( to RMAN catalog)
RMAN > catalog start with 'E:\indika\backup’;
NOTE: E:\indika\backup path contains the source database backups
6) In order to restore the database for last committed transaction. It’s required to know the last log sequence available in the archive log backup. This will help us in recovering the database till that archivelog.
RMAN > list backup of archivelog all;
Note down the last sequence number..
7) Switch to SQLPLUS to extract data file path and redo log path where source database had, which are required to relocate to the target database. Since the source backups have been cataloged to target database those path can be extracted easily
Output of the below query would use in RMAN script to restore and recover purpose
SQL>SELECT FILE# AS "File/Grp#", NAME FROM V$DATAFILE – data file paths
SQL>SELECT GROUP#,MEMBER FROM V$LOGFILE; – log file paths
8) Restore and Recover target database
Switch to RMAN
CMD> RMAN target /
RMAN> run
{
# Do a SET UNTIL to prevent recovery of the online logs
set until sequence 4;
# rename/re-locate the datafiles to new path
set newname for datafile 1 to 'C:\app\oracle\oradata\totanew\system01.dbf';
set newname for datafile 2 to 'C:\app\oracle\oradata\totanew\sysaux01.dbf';
set newname for datafile 3 to 'C:\app\oracle\oradata\totanew\undotbs01.dbf';
set newname for datafile 4 to 'C:\app\oracle\oradata\totanew\users01.dbf';
# rename/re-locate the log files to new path
SQL "ALTER DATABASE RENAME FILE ' C:\app\oracle\oradata\tota\redo01.log''
TO 'C:\app\oracle\oradata\totanew\redo01.log'' ";
SQL "ALTER DATABASE RENAME FILE ' C:\app\oracle\oradata\tota\redo02.log''
TO 'C:\app\oracle\oradata\totanew\redo02.log'' ";
SQL "ALTER DATABASE RENAME FILE ' C:\app\oracle\oradata\tota\redo03.log''
TO 'C:\app\oracle\oradata\totanew\redo03.log'' ";
# restore the database and switch the datafile names
restore database;
switch datafile all;
# recover the database
recover database;
alter database open resetlogs;
}
Source server
Pre request on source database:
• Source server should run on archive log mode.
• Following configuration should enable in RMAN
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
• Target server oracle binary should be installed
1) Backup the database with archive logs
RMAN> backup database plus archivelog;
Copy all the backup pieces to target server, which should include the following backup pieces
• Backup of Datafiles
• Backup of archivelogs
• Backup of SPFILE and CONTROL files
Target server
1) Create dummy instance ,which would be the target database SID
CMD >oradim -new -sid totanew
CMD >set oracle_sid=totanew
NOTE: totanew is new target database SID
2) Connect to the RMA and restore the SPFILE from backup
CMD>rman target /
RMAN>startup nomount
This would start dummy instance call totanew
RMAN> RESTORE SPFILE TO PFILE 'C:\app\oracle\product\11.2.0\dbhome_1\database\inittotanew.ora' FROM 'E:\indika\backup\O1_MF_S_828200600_9552B1J6_.BKP';
NOTE: E:\indika\backup path contains the source database backups
NOTE: inittotanew.ora file name convention is init<NEW SID>.ora
RMAN>startup force nomount;
3) Next, edit the restored PFILE called inittotanew.ora.
Create the necessary directories in the target server
*.audit_file_dest='C:\app\oracle\admin\totanew\adump'
*.control_files='C:\app\oracle\oradata\totanew\control01.ctl',
'C:\app\oracle\flash_recovery_area\totanew\control02.ctl'
*.db_recovery_file_dest='C:\app\oracle\flash_recovery_area'
NOTE: Sometime in windows it’s required to close command prompt and start new one in order to
Save the changes to new INITtotanew.ora. File
RMAN>shutdown immediate
Next restart the instance with modified PFILE
RMAN >startup nomount pfile=’C:\app\oracle\product\11.2.0\dbhome_1\database\INITtotanew.ORA’
4) Restore control file from backup
Connect to the RMA
RMAN >restore controlfile from 'E:\indika\backup\O1_MF_S_828200600_9552B1J6_.BKP';
RMAN >alter database mount
NOTE: E:\indika\backup path contains the source database backups
5) Register the backup pieces in to target database ( to RMAN catalog)
RMAN > catalog start with 'E:\indika\backup’;
NOTE: E:\indika\backup path contains the source database backups
6) In order to restore the database for last committed transaction. It’s required to know the last log sequence available in the archive log backup. This will help us in recovering the database till that archivelog.
RMAN > list backup of archivelog all;
Note down the last sequence number..
7) Switch to SQLPLUS to extract data file path and redo log path where source database had, which are required to relocate to the target database. Since the source backups have been cataloged to target database those path can be extracted easily
Output of the below query would use in RMAN script to restore and recover purpose
SQL>SELECT FILE# AS "File/Grp#", NAME FROM V$DATAFILE – data file paths
SQL>SELECT GROUP#,MEMBER FROM V$LOGFILE; – log file paths
8) Restore and Recover target database
Switch to RMAN
CMD> RMAN target /
RMAN> run
{
# Do a SET UNTIL to prevent recovery of the online logs
set until sequence 4;
# rename/re-locate the datafiles to new path
set newname for datafile 1 to 'C:\app\oracle\oradata\totanew\system01.dbf';
set newname for datafile 2 to 'C:\app\oracle\oradata\totanew\sysaux01.dbf';
set newname for datafile 3 to 'C:\app\oracle\oradata\totanew\undotbs01.dbf';
set newname for datafile 4 to 'C:\app\oracle\oradata\totanew\users01.dbf';
# rename/re-locate the log files to new path
SQL "ALTER DATABASE RENAME FILE ' C:\app\oracle\oradata\tota\redo01.log''
TO 'C:\app\oracle\oradata\totanew\redo01.log'' ";
SQL "ALTER DATABASE RENAME FILE ' C:\app\oracle\oradata\tota\redo02.log''
TO 'C:\app\oracle\oradata\totanew\redo02.log'' ";
SQL "ALTER DATABASE RENAME FILE ' C:\app\oracle\oradata\tota\redo03.log''
TO 'C:\app\oracle\oradata\totanew\redo03.log'' ";
# restore the database and switch the datafile names
restore database;
switch datafile all;
# recover the database
recover database;
alter database open resetlogs;
}
No comments:
Post a Comment