Computer >> Computer tutorials >  >> Programming >> Database

Recover a physical standby database by using an incremental backup

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

Introduction

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 primary and standby site

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

Primary site:

Recover a physical standby database by using an incremental backup

Standby site:

Recover a physical standby database by using an incremental backup
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:

Recover a physical standby database by using an incremental backup

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

Primary site:

Recover a physical standby database by using an incremental backup

Standby site:

Recover a physical standby database by using an incremental backup

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 the 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):

Recover a physical standby database by using an incremental backup

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:

Recover a physical standby database by using an incremental backup
Step 3: Incremental backup

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

Recover a physical standby database by using an incremental backup Recover a physical standby database by using an incremental backup Recover a physical standby database by using an incremental backup
Step 4: Back up the standby control file

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

Recover a physical standby database by using an incremental backup
Step 5: Ship the backups across to the standby site

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

Recover a physical standby database by using an incremental backup
Step 6: Restore the standby control file

Restore the control file on the standby site:

Recover a physical standby database by using an incremental backup

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:

Recover a physical standby database by using an incremental backup Recover a physical standby database by using an incremental backup Recover a physical standby database by using an incremental backup
Step 7: Catalog the backup pieces

Now, catalog the backup process:

Recover a physical standby database by using an incremental backup Recover a physical standby database by using an incremental backup Recover a physical standby database by using an incremental backup Recover a physical standby database by using an incremental backup
Step 8: Catalog existing data files

Also, catalog your existing data files:

Recover a physical standby database by using an incremental backup
Step 9: Switch the existing data files

Switch all existing data files to their image copies:

Recover a physical standby database by using an incremental backup
Step 10: Recover the database

Now, recover your database:

Recover a physical standby database by using an incremental backup Recover a physical standby database by using an incremental backup

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:

Recover a physical standby database by using an incremental backup

Standby site:

Recover a physical standby database by using an incremental backup
Step-12: Start Media Recovery

Start media recovery on the standby site:

Recover a physical standby database by using an incremental backup

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.

Use the Feedback tab to make any comments or ask questions. You can also start a conversation with us.