Recover a physical standby database by using an incremental backup

By Rackspace Technical Staff

Introduction

A standby database is a consistent copy of the production database, which helps in production disasters, data loss, or corruption.

The following reasons might account for a lag between a primary and a standby site:

  1. Network bandwidth issues between primary and standby databases.
  2. Unavailability of the standby database.
  3. Accidental deletion of archive redo data on the primary database.

You can sync primary and standby environments by copying and applying archive logs from the primary site, but this process is very time-consuming.

Another option is to recover the standby site using incremental RMAN backup of the primary site. You can also use this method when you have missing archived logs on the primary that the system never applied to the standby database.

Steps to recover a physical standby database by using an incremental RMAN backup

To set up this scenario, I manually removed some of the archive logs from the primary site to simulate corrupt logs or missing logs. 

Step 1: Check the sync status of the primary and standby site

You need to take a quick look at the sync status between the primary (prod) and standby (stby).

Primary site:

standby db pic 1

Standby site:

standby db pic 2

Step 2: Simulate a gap between the primary and standby 
You need to log on to the primary database and alter LOG_ARCHIVE_DEST_STATE_2 to DEFER. Then do the same manual log switches to generate some archive logs, thus creating a gap between primary and standby:

standby db pic 3

Now, if you take a look at the CURRENT_SCN between primary and standby, the standby isn't catching up because you have manually disabled the sync. 

Primary site:

standby db pic 4

Standby site:

standby db pic 5

 

If you now re-enable LOG_ARCHIVE_DEST_STATE_2, the standby automatically catches up. But you should not go for that option right away. To create a gap simulation, you need to delete the archive logs manually from the primary site.

Ensure that in both sites, you do not have archive logs later than 232 and 218 for threads 1 and 2, respectively.

Now, you need to re-enable LOG_ARCHIVE_DEST_STATE_2 (set to ENABLE):

standby db pic 6

As expected, the standby cannot continue applying the logs because some of the logs are missing from the primary site.

Finally, cancel the recovery and shut down the standby instance:

standby db pic 7

Step 3: Incremental backup 

Log on to the primary and take an incremental backup from the last SCN applied at the standby:

standby db pic 8a
standby db pic 8 b

 

standby pic 8 c

Step 4: Back up the standby control file 

Now, back up the control file on the standby site:

standby db pic 9

 Step 5: Ship the backups across to the standby site

Transfer the incremental backup that you just took to the standby site:

standby db pic 10

Step 6: Restore the standby control file

Restore the control file on the standby site:

standby pic 11

Note: Ensure that you manually remove the old control files before executing the preceding commands to confirm that you are using the control files. 

Log on as a grid user and remove the old control files:

standby db 12 a
standby db 12 b

 

standby db 12 c

Step 7: Catalog the backup pieces 

Now, catalog the backup process:

standby db 13 a

 

standby db pic 13 b

 

standby db 13 c pic
standby db 13 d

 Step 8: Catalog existing data files

Also, catalog your existing data files:

standby db pic 14

Step 9: Switch the existing data files 

Switch all existing data files to their image copies

standby db pic 15

Step 10: Recover the database 

Now, recover your database:

standby db 16a
standby db pic 16 b

 This step concludes the standby refresh. Just a few more steps to go!

Step 11: Check the sync status

Take a quick look at the sequences across both sites. Notice that the standby  caught up with the primary:

Primary site:

db standby pic 17

 Standby site:

standby db pic 18

Step-12: Start Media Recovery 

Start media recovery on the standby site:

standby db pic 19

Conclusion 

With the help of the preceding steps, you can recover the standby site. Using an incremental backup of your production environment saves a considerable amount of time.

Learn more about our Database services