Wednesday, November 27, 2024

 

RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time

https://shivanandarao-oracle.com/2012/12/05/rman-20207-until-time-or-recovery-window-is-before-resetlogs-time/

KB0013276

When you are performing a PITR (Point In Time Recovery), you might have undergone the error “RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time”. The reason that RMAN throws this error is when you are trying to perform a PITR of the database to a time before the database was last opened with RESETLOGS. In other words, the time you specify in the “until time” clause of RMAN is the time that the database was in its previous incarnation and not the CURRENT incarnation.


RMAN threw an error saying “RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time”.

executing command: SET until clause
Starting restore at 01-DEC-12
Starting implicit crosscheck backup at 01-DEC-12
RMAN-00571: ===================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =======
RMAN-00571: ===================================================
RMAN-03002: failure of restore command at 12/01/2012 20:26:41

RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time

RMAN is trowing this error because the incarnations of the database not matching with PITR. 
Run the “list incarnation” command at RMAN prompt.

 
rman target / catalog /@<rman catalog>

RMAN>spool log to <caseid>_restore.log
RMAN>set echo on
RMAN>ALTER SESSION SET NLS_DATE_FORMAT = 'dd/mm/yyyy hh24:mi:ss';
RMAN>list incarnation of database;
 

DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
294105469 294105470 AMALPRD1 1914393966       PARENT  1          21-AUG-2023 01:21:50
294105469 625758845 AMALPRD1 1914393966       CURRENT 9029509056 26-NOV-2024 15:39:15

** reset database to incarnation <n>;  <-- only if required; n = the appropriate INC Key that your restore until_time falls into, i.e. before resetlogs time)

RMAN> reset database to incarnation 1;

run {
  allocate channel ch00 type disk;
  set until time= "to_date('14/06/2022 14:30:00','dd/mm/yyyy hh24:mi:ss')";
  restore database preview summary;
  release channel ch00;
}

shutdown immediate;
** set dbid=<dbid>;  <-- only required if the DBID is different, otherwise no need to set it.

run {
startup nomount;
set until time= "to_date('14/06/2022 14:30:00','dd/mm/yyyy hh24:mi:ss')";
restore controlfile;
alter database mount;
restore database;
recover database;
}
alter database open resetlogs;
select * from v$instance;
select con_id, dbid, name, open_mode, restricted, open_time from v$containers;

spool log off;
exit;

Wednesday, April 10, 2024


Query to Check available Space of an Oracle Database


Login to the database as SYS user

sqlplus as / sysdba

Then copy and paste below sql query in the command line or PL/SQL editor

select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || ' GB' "Database Size",
round(sum(used.bytes) / 1024 / 1024 / 1024 ) -
round(free.p / 1024 / 1024 / 1024) || ' GB' "Used space",
round(free.p / 1024 / 1024 / 1024) || ' GB' "Free space"
from (select    bytes
from v$datafile
union all
select bytes
from v$tempfile
union all
select bytes
from v$log) used,
(select sum(bytes) as p from dba_free_space) free
group by free.p;

  RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time https://shivanandarao-oracle.com/2012/12/05/rman-20207-until-time-or-re...