1

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?

1 Answer 1

1

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;
6
  • is there any possibility to restore data from those files without additional commands on that database? at this moment the only thing I have is these files Sep 12, 2016 at 3:32
  • 1
    This answer points to the solution. You are backing up your database and archive logs before you backup the control file. When the control file is newer than the database backup, you need to roll forward with archive log files to bring the database into a known state. The answer is to backup the control file first, then backup your database, then backup your archive logs. The above script needs to specify backing up the control file as a part of backing up the database. Then it should be valid since you are forcing a log switch after the database backup and before the backup of archive logs.
    – Gandolf989
    Sep 12, 2016 at 14:45
  • Instead of backing up the individual components in sequence, just use "backup database plus archivelog". Sep 12, 2016 at 16:29
  • The controfile is not used in that way, @Gandolf989, but I agree that it would not hurt to include specific instructions for a controlfile copy, snapshot or trace, although Oracle reccommends controfile autobackup when RMAN is used without a catalog. If controlfile autobackup is not enabled RMAN defaults to include a copy of the controlfile in every backup set that includes data file 1.
    – Roy
    Sep 12, 2016 at 16:42
  • @cinek181992 As long as you have not forced an open resetlogs, I would think that you can do (well, pretend to, anwyay) incomplete media recovery and avoid the ORA-1547. I will update my answer to include this possibility.
    – Roy
    Sep 12, 2016 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.