Practical RMAN Restore Scenario For Linux on Different Server
Practical RMAN Restore Guide
This quick guide shows how to restore and relocate an Oracle database
via RMAN. We’ll assume you want all datafiles in a new folder
(/newpath
instead of /oldpath
), and possibly
handle redo logs in a new location as well.
1. Copy RMAN Backups to the New Server
mkdir -p /u01/backup/test_restore
cp /oldserver/backups/*.bkp /u01/backup/test_restore
Explanation: Make sure you copy all backup pieces (datafiles, control file, SPFILE, archivelogs) to a directory the new server can access.
2. Start with a Minimal PFILE in NOMOUNT
sqlplus / as sysdba
-- Create or use a small init file:
STARTUP NOMOUNT PFILE='/u01/app/oracle/product/19.0.0/dbhome_1/dbs/initMYDB.ora';
Explanation: You can’t restore the control file or SPFILE unless the instance is NOMOUNT.
3. Restore the Control File & Mount the Database
rman target /
RESTORE CONTROLFILE FROM '/u01/backup/test_restore/controlfile_backup.bkp';
ALTER DATABASE MOUNT;
Explanation: Once the control file is restored, we can mount the database so RMAN knows the datafile structure.
4. Use SET NEWNAME FOR DATABASE TO '/newpath/%b'
RUN {
SET NEWNAME FOR DATABASE TO '/newpath/%b';
RESTORE DATABASE;
SWITCH DATAFILE ALL;
RECOVER DATABASE;
}
Explanation:
SET NEWNAME FOR DATABASE TO '/newpath/%b'
: This redirects all datafiles to/newpath
, using the original base filename (%b
).RESTORE DATABASE
: Copies datafiles from backup to/newpath
.SWITCH DATAFILE ALL
: Updates the control file so Oracle knows the new datafile locations.RECOVER DATABASE
: Applies archive logs to bring datafiles up to date.
5. Handle Redo Logs in a New Location (Optional)
If Oracle still expects redo logs under /oldpath
(and you can't
drop or clear them easily), rename or recreate them in /newpath
.
a) Rename the Logs
ALTER DATABASE RENAME FILE
'/oldpath/onlinelog/o1_mf_3_abc.log'
TO
'/newpath/onlinelog/o1_mf_3_abc.log';
Explanation: Tells Oracle the redo log group now resides in
/newpath
.
b) touch
Zero-Byte Files if Needed
mkdir -p /newpath/onlinelog
touch /newpath/onlinelog/o1_mf_3_abc.log
Explanation: If Oracle complains it can’t find the file, creating a blank
placeholder sometimes helps so CLEAR LOGFILE GROUP x
or
OPEN RESETLOGS
can succeed.
6. Open the Database with RESETLOGS
ALTER DATABASE OPEN RESETLOGS;
Explanation: Finalizes the restore, discards old redo logs, and starts a fresh set.
7. Verify Everything
SELECT name FROM v$datafile;
SELECT group#, member FROM v$logfile;
Explanation: Confirm all datafiles and redo logs now point to
/newpath
(instead of /oldpath
).
Summary
- Copy backups to the new server.
- Startup NOMOUNT with a minimal PFILE.
- Restore the control file and MOUNT the database.
SET NEWNAME FOR DATABASE
and restore/recover datafiles.- Rename or recreate any redo logs if needed.
- Open the database with
RESETLOGS
. - Check your datafile/redo log paths.
That’s it! You’ve relocated and restored an Oracle database to a new path with minimal fuss.
Comments
Post a Comment