How to Restore Database until time

Hi, in this practice, we will restore database until a specific time in the past, or restore database until time.

Restore Database until time

RMAN restoration until time script.

Restore Database until time

Step 1: Set environment

For Windows: set ORACLE_SID=orcl
For Linux/AIX: export ORACLE_SID=orcl

Step 2. Start Database nomount

Start your database till the nomount stage using pfile.

$sqlplus / as sysdba
SQL>startup nomount pfile=/u01/initORCL.ora';

Step 3: Restore Controlfile (optional)

Restore controlfile from backup.

$rman target/
RMAN> restore controfile from '/u01/rman_bkp/controlfile.bkp';
RMAN> startup mount;

After controlfile restoration, startup database in mount mode.

Step 4: Start Restoration and Recovery

Use one of the below scripts.

Script 1:

$rman target / 
RMAN>restore database UNTIL TIME "to_date('07/06/2022 11:34:50 am','mm/dd/yyyy hh:mi:ss am')";
RMAN>recover database UNTIL TIME "to_date('07/06/2022 11:34:50 am','mm/dd/yyyy hh:mi:ss am')";
RMAN>alter database open resetlogs;

Script 2:

RMAN> run
 {
set UNTIL TIME "to_date('07/06/2022 11:34:50 am','mm/dd/yyyy hh:mi:ss am')";
restore database;
recover database;
alter database open resetlogs;
}

You must read: DATAGUARD

Note: You must enter the right data and time.

Leave a Comment