Restoring Oracle Database using Rman I have a problem with restoring the database using RMAN. I have a script that does a full backup of the database every one week. Logs show that the backup was created correctly.

set ORACLE_SID=MY_DB
set LOGFILE=path/full_%DATE%.log
set CMDFILE=path/restore.config

rman target / nocatalog cmdfile=%CMDFILE% msglog %LOGFILE%;

restore.config
run {
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
backup as compressed backupset incremental level 0 database format '\\path\data_%Y_%M_%D.%U';
backup as compressed backupset archivelog all delete all input format '\\path\archive_logs_%Y_%M_%D.%U';
backup as compressed backupset current controlfile format '\\path\control_files_%Y_%M_%D.%U';
backup as compressed backupset spfile format '\\path\spfile_%Y_%M_%D.%U';
CROSSCHECK BACKUP;
delete noprompt obsolete recovery window of 0 days;
}


Backup files are located on another server.
I prepared the file, which was to restore the database from the backup.

run {
shutdown immediate;
startup mount;
catalog start with 'path to dump files';
restore database;
recover database;
alter database open;
}


After this command I have this error:

unable to find archived log
archived log thread=1 sequence=13407
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/26/2016 12:16:26
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 13407 and starting SCN of 111916667960

Recovery Manager complete.


Then I reworked the script but it did not help:

run {
shutdown immediate;
startup nomount;
restore controlfile from 'path to control file';
shutdown immediate;
startup mount;
catalog start with 'path to dumps\';
restore database;
recover database;
alter database open resetlogs;
}


and now i have this error:
Oracle Error:

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: 'Path to db\SYSTEM01.DBF'


I would add that if I create a base and tries to create a backup and then restore it then these commands works.

Could someone explain to me why it does not work and how can I restore the database from this backup?
Both errors indicate that you need more archive log to complete media recovery and bring your data files to a consistent state. 

If the datafiles are newer than the redo data you have available, the the alternative is to grab an older backup of the datafiles and work from there with the redo data you do have from the latest backup run. A common strategy is to continuously send archive logs to a backup destination between backups, and in that way minimizing the loss of data leading up to the next scheduled backup.

If you would rather aim to get an independently consistent backupset, you need to capture all the datafiles as well as all of the redo generated while backup was running. I would suggest something like this sequence of backup operations:

run{ 
backup database ;
sql 'alter system switch logfile';
sql 'alter system archive log current';
backup archivelog all ; 
}


Note how you would first complete the database backup, then force a switch to the next log group before triggering an archive process and finally start backing up the archived logs. Those logs now have a much better chance of containing the redo data you need to run media recovery on files restored from this backup set.

UPDATE: 

In your current situation, if this really is all the data you have to work with, I think you should still be able to bypass the ORA-1547 by pretending to do a manual incomplete media recovery and then open with resetlogs.

STARTUP FORCE MOUNT
RECOVER DATABASE UNTIL CANCEL;
CANCEL;
ALTER DATABASE OPEN RESETLOGS;