Restoring using RMAN
RMAN is a Recovery Manager tool used for restorations and backups. It has gained its popularity due to the simplicity of use.
In this article we will not get into much detail of what RMAN is and how it works. We’ll leave that for a later topic. Instead, we will devote this article to defining the process required in order to perform a RMAN restoration from a previously taken backup.
- Check if the database is asm
ps -ef | grep pmon
- If asm, drop the database
sqlplus / as sysdba
startup mount exclusive restrict;
drop database;
- Change SID
Export ORACLE_SID=XXX
- Check which restoration backup needs to be restored (basically the date and time and source area)
- Edit the rman script with the date and the time. Ensure that the correct area is selected. Go to the directory which contains your rman scripts to open and edit
cd XXXXXX
vi restore_from_backup.rman
- Check the rman and sh scripts
If the archive logs have been backed up, we can restore and recover at the same time by including the following commands after restoring the database and control files
alter database mount;
recover database delete;
- If the area is not ASM, you will need to manually remove the control files, redo files, index files and data files. The database will need to be in nomount state (since we will be removing the control file)
a) First, find the location of these files
sqlplus / as sysdba
select * from v$datafile
select * from v$controlfile
select * from v$redolog
select * from v$tempfile
b) Shutdown database
shutdown immediate;
c) Start up without mount
startup nomount;
exit;
d) Go to directories and remove files
pwd
cd ../oradata/XXXX
pwd
ls -lrt
Go to each directory
cd XXXXXXX
rm *
- Execute restore script with no hangups
nohup ./restore_from_backup.sh &
- Tail the log file onto the screen
tail -f restore_from_backup.log
- When log starts displaying read/writes
a) Open new session
b) Log in
c) Go into nsrwatch
nsrwatch
d) Search for ‘starting read from … ‘
- When restore is finished, if it is an older backup, please do the following
a) Open resetlogs
alter database open resetlogs;
b) Shutdown database
shutdown immediate;
c) Start up with mount (we need the control file)
startup mount;
d) Set to no archive mode (if not production only)
alter database noarchivelog;
e) Open database
alter database open;
And, you’re done!