Resync Oracle Standby DB Without a Full Rebuild

Share:
Article Summary

Learn how to resync an Oracle Data Guard standby database using RMAN incremental backup — faster than a full rebuild, step by step.

Every DBA managing an Oracle Data Guard setup eventually faces this situation. The standby database has fallen behind the primary, archive logs are missing, and managed recovery refuses to start. Most people assume a full standby rebuild is the only way out — but that can take hours or even an entire day depending on database size.

There is a smarter approach. By taking an RMAN incremental backup from the primary database at the standby’s current SCN, you can bring everything back in sync without moving the full database. This method is faster, less disruptive, and works even when the redo gap is large.


Why Does a Standby Fall Out of Sync?

Understanding the root cause helps you prevent it from happening again. A standby loses sync when it stops receiving or applying redo data from the primary. Common causes include:

Archive logs deleted on the primary before the standby could apply them — this usually happens when the Fast Recovery Area fills up or the retention policy is too aggressive. Network interruptions that break the redo transport stream for an extended period are another frequent culprit. Disk failures on the standby side can cause datafile corruption or log apply errors. A long maintenance window where the standby was intentionally taken offline also creates a gap. In all these situations, a full rebuild feels like overkill. The incremental backup approach targets exactly the missing data and nothing more.


How the Incremental Resync Method Works

The logic behind this approach is simple. Every Oracle datafile block carries an SCN stamp that records when it was last changed. When you take an RMAN incremental backup from the primary starting at the standby’s lowest SCN, Oracle collects only the blocks modified since that point. Those changed blocks are then applied directly to the standby datafiles, fast-forwarding them to match the primary. After that, normal redo apply closes the remaining gap automatically.

No full export. No duplicate operation. No unnecessary data movement across the network.


Before You Begin

Check that you have enough disk space on both servers for the incremental backup. Depending on how far behind the standby is, the backup size can vary significantly. Confirm that the Oracle OS user on the standby has SSH access from the primary, since files need to move between servers. Also note your current standby datafile paths — you will need them later if they differ from the primary.


Step 1 — Find the Correct Starting SCN on the Standby

This is the most critical step in the entire process. An incorrect SCN will cause recovery to fail or leave the standby in a broken state. Connect to the standby and run the following queries:

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';

The third query is the most reliable because it reads the SCN header of every writable datafile and returns the absolute lowest value. Use that number as your starting SCN. When uncertain, subtract a small buffer from it — starting the backup slightly earlier is always safer than starting it too late.


Step 2 — Stop Managed Recovery and Shut Down the Standby

An incremental backup cannot be applied to a running database. Cancel the Managed Recovery Process first, then shut the standby down cleanly.

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SHUTDOWN IMMEDIATE;

If the shutdown hangs, run SHUTDOWN ABORT followed by a clean startup and shutdown cycle. A consistent shutdown ensures all datafile headers are in a recoverable state before you proceed.


Step 3 — Take the Incremental Backup on the Primary

Connect to the primary database through RMAN and run the backup using the SCN you identified in Step 1. The primary stays online throughout this operation — no downtime is needed.

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

Replace 4829301 with your actual SCN value. The %U placeholder generates unique filenames automatically. If RMAN has multiple channels configured, the backup runs in parallel and finishes faster.


Step 4 — Back Up the Current Archived Logs

This step is often skipped in other guides, but it is important. After the incremental backup is applied, the standby still needs archived logs to reach real-time sync. Back them up now so they are ready to transfer alongside the incremental pieces.

BACKUP ARCHIVELOG ALL
FORMAT '/oracle/backup/arch_%U.bkp';

Step 5 — Transfer All Backup Files to the Standby Server

Copy both the incremental backup and the archived log backup to the standby host.

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

For large files, rsync is a better option as it compresses data during transfer and can resume automatically if the connection drops midway.


Step 6 — Generate a Fresh Standby Control File on the Primary

The existing standby control file may be outdated. A fresh one must be created from the primary and transferred to the standby server.

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

Always generate a new control file for this procedure. Reusing an old one risks inconsistencies between what the control file records and what actually exists on disk.


Step 7 — Start the Standby Instance in NOMOUNT Mode

On the standby server, bring up the instance without mounting any database. At this point, Oracle reads only the parameter file.

STARTUP NOMOUNT;

Step 8 — Restore the Control File via RMAN

Connect to the standby instance through RMAN and restore the control file you transferred in Step 6.

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

Step 9 — Mount the Standby Database

ALTER DATABASE MOUNT STANDBY DATABASE;

Step 10 — Catalog the Backup Files in RMAN

RMAN needs to register the backup pieces before it can use them for recovery. Run a catalog scan pointing to the backup directory.

CATALOG START WITH '/oracle/backup/';

This scans all files in the directory and registers both the incremental backup and the archived log backup in the control file. Verify that RMAN picks up all the files before moving forward.


Step 11 — Remap Datafile Paths If Needed

Skip this step if your primary and standby servers use the same directory structure for datafiles. If the paths differ — which is common when the standby was built on different storage — you need to remap them before recovery.

CATALOG START WITH '/standby/oradata/';
SWITCH DATABASE TO COPY;

The SWITCH DATABASE TO COPY command updates the control file so all datafile references point to their correct standby locations. Missing this step is one of the most common reasons resync operations fail in cross-server environments.


Step 12 — Apply the Incremental Backup

Now apply the incremental backup to the standby datafiles. The NOREDO option tells RMAN not to apply redo at this stage — that happens later through managed recovery.

RECOVER DATABASE NOREDO;

Completion time depends on how many changed blocks were backed up. Watch the RMAN output carefully and make sure it finishes without errors before moving to the next step.


Step 13 — Start Managed Recovery Process

With the incremental backup successfully applied, restart MRP. It will begin applying archived logs and eventually switch to real-time redo apply once it catches up with the primary.

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

The DISCONNECT FROM SESSION option runs MRP in the background so your session stays free for other work.


Verifying the Standby Is Back in Sync

Check the MRP process to confirm it is actively applying redo data from the primary.

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

A status of APPLYING_LOG means recovery is in progress. A status of WAIT_FOR_LOG means the standby has caught up and is waiting for new redo — both are healthy outcomes.

Run this query to check for any remaining archive gaps.

SELECT * FROM V$ARCHIVE_GAP;

No rows returned means no gaps exist. If rows do appear, transfer the missing sequences from the primary and register them manually before MRP can continue.

To measure how close the standby is to the primary, compare the last applied sequence on the standby against what the primary is currently generating.

-- Run on standby
SELECT MAX(SEQUENCE#), APPLIED
FROM V$ARCHIVED_LOG
GROUP BY APPLIED;

Mistakes That Will Break This Process

Using the wrong SCN is the most common error. The backup must start from the lowest SCN across all writable datafiles — not the current database SCN. Even one missed block will cause recovery to fail.

Skipping the archived log backup means the standby will apply the incremental backup successfully but then stall waiting for log files that were never transferred.

Reusing an old control file instead of generating a fresh one from the primary can cause mismatches between what the control file expects and what physically exists on the standby server.


Wrapping Up

The RMAN incremental backup resync method solves a problem that most DBAs assume needs a full rebuild — and it does so in a fraction of the time. Once you have run through this procedure, it becomes the first tool you reach for whenever a standby has fallen too far behind for normal recovery.

Getting the SCN right in Step 1 is everything. Nail that, and the rest of the procedure is straightforward.

Was this helpful?

Written by

W3buddy
W3buddy

Explore W3Buddy for in-depth guides, breaking tech news, and expert analysis on AI, cybersecurity, databases, web development, and emerging technologies.