I just started working with oracle and I have some issue.
My database is NONARCHIVELOG mode.
I made two backups:
they are at locations:
/opt/oracle/flash_recovery_area/CTGINST1/backupset/ol_mf_____20130408.bkp
/opt/oracle/flash_recovery_area/CTGINST1/backupset/ol_mf_____20130407.bkp
I want to restore second file from 7th April.
I read some guide on:
http://orafusion.com/art_rman3.htm
but I can not find command how to specify restore command with specific backup files from these two (or more). It does not say on this link and on other links I read.
I want to use it with RMAN commands.
what will be the commands to restore my older backup?
I found
RMAN> restore database;
but how it will know what file to restore?
Also does it always need to restore spfile and control file because I did not create some additional backups (just ran command backup database
)
Thank you!!
Best Answer
TL;DR: Just supply the tag of the backup you want to restore the database from, for example
restore database from tag 'INTERESTING_TAG';
DISCLAIMER
The solution provided here is based solely on my own experience, you use it on your own risk. I'm not liable for any damages (including data loss) caused by using this solution.
By default RMAN is configured to automatically back up control file and spfile after every successful backup and on every database structural change (for example, adding datafiles) which causes these changes to be reflected in control files. Thus after every successful database backup with
backup database
, the spfile and control file will be automatically backed up.You can determine if autobackup is enabled by issuing
show controlfile autobackup;
in RMAN, and enable it sayingconfigure controlfile autobackup on;
in RMAN.Since you supplied the paths to the backup sets you want to restore your database from, I assume that you obtained them from your current control file using RMAN. It won't hurt to save this information and other information about your existing backups to a plain text file because you will restore one of the previous control files and chances are this information will be lost:
You'll need to restore your database AND control file(s), because the database datafile headers of every datafile should be in sync with control file(s), i. e. they should have the same System Change Number (SCN).
As I already said, you just need to supply the tag name to restore the database from a specific backup. You can determine which tags were assigned to the backups by you or by the system, the completion date and time of the backups, and other information about backups saying
list backup
in RMAN (we already saved this info to the text file). Here's the output oflist backup
in my sample installation:From this output, you can see that the first backup was (automatically) assigned the tag
TAG20130410T050852
, and that the control file and spfile autobackup follows immediately (check the Completion Time field). You can also see that I performed another database backup, and I manually assigned it the tagDELETE_ME
, and, of course, it's immediately followed by autobackup too. Notice also that the files in every backup have the same SCN, and that SCNs match the SCNs of the control files in the adjacent autobackups.We will restore the database from the backup tagged
TAG20130410T050852
which is older than the other backup taggedDELETE_ME
, and we will restore the control file from the autobackup first.In order to restore the control file from backup with RMAN, your instance should be in
NOMOUNT
state (only spfile is accessed in this state by the instance–control file(s) and datafiles are not accessed):(Though, you may use
abort
clause instead ofimmediate
, and Oracle won't bother shutting down the database orderly–you'll restore it from the previous backup anyway.)Restore the controlfile from autobackup:
In order for RMAN to be able to read backup records in control file (just like it did when we were issuing
list backup
), we need to put the database inMOUNT
state:We're now ready to restore the database:
The final step is to open the database:
We specified
resetlogs
clause here because the existing redo log files are no longer usable since they were in use by the previous database, and thus should be reset so that they can be used by the restored database.Now query for great good!