Backup and Restore with RMAN Oracle 12c I'm trying using RMAN to create and restore backups. I'm getting an error stack trace when trying to restore to one of the backups that I have made. The error is 

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/01/2016 11:52:10
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 30 and starting SCN of 2586064415


My backup RMAN script is as follows, and is run through an application where the parameters are filled in correctly.:

configure channel device type disk clear;
run {{ 
 allocate channel ch1 type Disk FORMAT '{0}\\BCKUP_%U' ;
 backup incremental level {1} database plus archivelog tag '{2}' ;
 backup spfile FORMAT '{0}\\SPFILE_%U' tag '{2}'; 
 backup current controlfile FORMAT '{0}\\CTRL_%U' tag '{2}'; 
}}


My restore script is:

run{
shutdown immediate
STARTUP FORCE NOMOUNT;
RESTORE CONTROLFILE FROM '...path to control file backup...';
ALTER DATABASE MOUNT;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS;
}


I can restore to the most recent backup just fine, but when I try to take another step back to one made prior I receive that error. Is there something in my script for either creating the backup or restoring that needs to change?

Files Created by backup:



Side Note: I run ALTER DATABASE OPEN RESETLOGS after I get the error and everything is working fine and dandy. The problem though, is that the application that will eventually do the restore will see the error message stack and classify it as a failed restore.

Parameters:


{0}: \\192.168.xxx.xxx\c$\backups\20160201_104531_INCREMENTAL\ (depending on backup type its INCREMENTAL or ONLINE_FULL)
{1}: 0/1 (depending on level)
{2}: INC_20160201_104531 (depending on backup type it's INC or FULL)
The control file backup loc: \\192.168.xxx.xxx\C$\BACKUPS\20160201_104814_INCREMENTAL\CTRL_0IQSQVKP_1_1
This is absolutely normal when you try to perform a complete recovery from a hot backup, because that is how hot backups work, you will never have the latest changes in your backups.

Your backup includes archivelogs up to sequence 29. The next changes were in log sequence 30, but log sequence 30 became the current redo log at the time your backup was finished, so you do not have any backup of that. This is not a problem, this is how a hot backups work, you will never have backups of the latest log sequence. Obviously, the next hot backup will back up that, but by the end of that backup, another sequence becomes the latest sequence.

If you simply try recover database;, RMAN tries to recover the database to the most current state, and it does not know where to stop (except when you have not only the archivelogs, but the redo logfiles also). Your last log sequence in the backup is 29, RMAN will complain about the next one, because it does not know where to stop. 

If you want to avoid the above error, you can explicitly specify RMAN where to stop (perform a point-in-time recovery). For example:

recover database until sequence 30;


This would have had the same result as your recover command, without throwing an error. You can also specify UNTIL SCN and UNTIL TIME.

30 because:


  When specifying log sequences, if the last created archived redo log
  has sequence n, then specify UNTIL SEQUENCE n+1 so that RMAN will
  apply n and then stop.


Or, you can just ignore this error and continue with alter database open resetlogs.