Resync Standby Database Using RMAN Incremental Backup (Oracle Data Guard)

Introduction

In an Oracle Data Guard environment, sometimes the standby database falls far behind the primary or archive logs are missing. In such cases, normal recovery fails and rebuilding the standby from scratch is time-consuming.

A faster and safer approach is to resynchronize the standby database using an RMAN incremental backup taken from the primary database starting at the standby’s SCN.

This blog explains the step-by-step procedure to resync a physical standby database using RMAN incremental backup.

When Do We Use This Method?

  • Missing archive logs on standby
  • Standby lag is very high
  • ORA- errors during managed recovery
  • Network or disk issues caused gap
  • Want to avoid full standby rebuild

Step 1: Check the Standby Database SCN

Connect to the standby database and identify the lowest SCN.

SELECT CURRENT_SCN FROM V$DATABASE;
SELECT MIN(fhscn) FROM X$KCVFH;
SELECT MIN(kc.fhscn)
FROM X$KCVFH kc, V$DATAFILE dd
WHERE kc.hxfil = dd.file#
AND dd.enabled != 'READ ONLY';

👉 Why this is important
RMAN incremental backup must start from the lowest SCN of standby, otherwise recovery will fail.

Step 2: Stop Managed Recovery and Shutdown Standby

On the standby database:

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SHUTDOWN IMMEDIATE;

👉 This ensures datafiles are consistent before applying incremental backup.

Step 3: Take Incremental Backup on Primary

Connect to the primary database using RMAN:

BACKUP INCREMENTAL FROM SCN <LOWEST_SCN>
DATABASE
FORMAT '/oracle/backup/increment_%U.bkp'
DEVICE TYPE DISK;

👉 This backup contains only the changed blocks since the standby SCN.

Step 4: Transfer Backup to Standby Server

Copy the RMAN backup to the standby host:

scp /oracle/backup/increment_*.bkp oracle@standby:/oracle/backup/

Step 5: Create Standby Control File on Primary

On the primary database:

ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/oracle/backup/standby.ctl';

Copy it to the standby server:

scp /oracle/backup/standby.ctl oracle@standby:/oracle/backup/

Step 6: Start Standby Database in NOMOUNT

On the standby database:

STARTUP NOMOUNT;

Step 7: Restore Standby Control File

Using RMAN on standby:

RESTORE STANDBY CONTROLFILE FROM '/oracle/backup/standby.ctl';

Step 8: Mount the Standby Database

ALTER DATABASE MOUNT STANDBY DATABASE;

Step 9: Catalog the Incremental Backup

Tell RMAN where the backup files are located:

CATALOG START WITH '/oracle/backup/';

Step 10: If Datafile Locations Differ (Important)

If primary and standby datafile paths are different, run:

CATALOG START WITH '/new_datafile_location/';
SWITCH DATABASE TO COPY;

👉 This maps datafiles correctly on the standby

Step 11: Recover the Standby Database

Apply the incremental backup:

RECOVER DATABASE NOREDO;

👉 NOREDO is used because redo will be applied later via MRP.

Step 12: Start Managed Recovery (MRP)

Finally, start redo apply:

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE
USING CURRENT LOGFILE
DISCONNECT FROM SESSION;

Verification

Check recovery status:

SELECT PROCESS, STATUS, THREAD#, SEQUENCE#
FROM V$MANAGED_STANDBY;

Check archive gap:

SELECT * FROM V$ARCHIVE_GAP;
This entry was posted in Oracle on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply