Monday, 28 May 2018

RMAN Incremental Backup for Rolling forward a Standby - Oracle Database

How to take backup while Rolling Forward the Standby - Oracle Database


What kind of backups are required to roll forward the standby database? Scripts required to take necessary backups for rolling forward a DR Site and bring it in sync with Primary.

rolling forward a standby using RMAN incremental backup


Well, normally there are 2 scenarios,

a) Either you are creating a Standby from the Scratch. OR

b) Somehow your DR is out of sync from a long time and there is a huge difference in applied log sequences on both sites due to which now you are looking for some method to bring it in SYNC with Primary.

This article is for the 2nd option. Just a basic to guide you how to begin. For rolling forward a Standby database, you must use RMAN incremental backup.

Please follow the below mentioned steps to know how to proceed:

1) Find out the minimum Checkpoint Change value in the database from which you need to take the backup. The below one will give you the System Change Number (SCN) value from the controlfile.

SQL> SELECT to_char(CURRENT_SCN) FROM V$DATABASE;

But it may not be the minimum checkpoint change for all the datafiles existing in your database. To check the same, use the below mentioned query.

SQL> select to_char(min(checkpoint_change#)) from v$datafile_header where file# not in (select file# from v$datafile where enabled = 'READ ONLY');

2) After you have known the minimum change value, you can take the RMAN incremental backup using the below mentioned query,

RMAN> backup incremental from SCN <SCN_Value> database format '/location_where_backup_will_be_done/backup_name_%U' tag '<anything like 4Standby>';

3) Also don't forget to create the standby controlfile from the Primary database. Use the below mentioned query to take controlfile backup,

RMAN> restore standby controlfile from '/location_where_controlfile_is_located/control_file_name.bkp';

Note: There are chances that from the time your DR has stopped being in SYNC with primary, some datafiles would have been added to the primary. If that's your case then you need to take the datafile backup as well to restore the same at the Standby before you recover your standby with incremental backup or the recovery will fail. Use the below mentioned query to take the datafile backup,

RMAN> backup datafile 1, 2, 3, 4 etc format '/location_where_backup_will_be_done/backup_name_%U' tag '<anything like 4Standby>';

You can use all of the 3 RMAN Backup taking commands as a whole using a run block. See below:

run {
backup datafile 1, 2, 3, 4 etc format '/location_where_backup_will_be_done/backup_name_%U' tag '<anything like 4Standby>';
backup incremental from SCN <SCN_Value> database format '/location_where_backup_will_be_done/backup_name_%U' tag '<anything like 4Standby>';
backup current controlfile for standby format '/tmp/ForStandbyCTRL.bck';
} 

I hope this helps !!

No comments:

Post a comment