Showing posts with label RMAN Backup. Show all posts
Showing posts with label RMAN Backup. Show all posts

Wednesday 24 September 2014

Roll Forward Physical Standby Database using RMAN incremental backup


There would be scenarios where the standby database lags far behind from the primary database leading to Archive Gap. It could be due to one of various reasons.It might be due to the network outage between the primary and the standby database leading to the archive gaps. While there is a network problem, some archived logs in primary database could have been deleted somehow.


Primary :

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    3187837
   
Standby :

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    3153120

In such cases where the standby lags far behind from the primary database, incremental backups can be used as one of the  methods to roll forward the physical standby database to have it in sync with the primary database.

Standby :
   
SQL -> recover managed standby database cancel;
SQL -> shutdown (immediate)

Primary :

RMAN -> backup incremental from scn 3153120 database format 'c:\incremental\inc_%U.bak';
SQL -> alter database create standby controlfile as  'c:\incremental\CONTROL03.ctl';
   
Standby :

SQL> startup nomount

copy & replace standby control files....
SQL> alter database mount standby database;

RMAN> catalog start with 'C:\incremental';
RMAN> recover database noredo;

SQL> alter database recover managed standby database disconnect from session;

RMAN-08138: WARNING: archived log not deleted - must create more backups




RMAN-08138: WARNING: archived log not deleted - must create more backups 


  • 1.       You should check your deletion_policy (if you delete with obsolete commad you should look at your retention policy)



  • 2.       It could be expired, so to delete archivelog :
                  delete noprompt expired archivelog all;


  • 3.       You could have given a unique name while taking backup, so you should correct it :

               Backup as copy tag = “unique_%d_%U” plus archivelog 

Thursday 18 September 2014

Backup Strategy In A Dataguard Environment : Delete ArchiveLogs Automatically



I have a system like the one show in figure. I want to backup database in primary and standby sites. Also, if there is a problem with shipment from primary to standby, i want to keep archived logs in primary i order to guarantee that when the problem is solved, unshipped archived logs will be shipped to standby. Problem can last more than the time specified with retention policy.


First, Configure RMAN to delete Archivelogs In Primary Database properly :


          RMAN -> CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO
                           ALL STANDBY BACKED UP <n> TIMES TO DEVICE TYPE <device_type>;

- Ensures that FRA logs are deleted only after being shipped and backed up.
- FRA space reclamation and RMAN delete honor deletion policy.



After that,  Configure RMAN to delete Archivelogs In Physical Standby Database.
  
      RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY BACKED UP <n> TIMES TO DEVICE TYPE <device_type>;
or 

       RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY BACKED UP <n> TIMES TO DEVICE TYPE <device_type>;


Primary backup rcv file :

run {
allocate channel t1 device type disk;
allocate channel t2 device type disk;
backup as copy database;
backup archivelog all;
release channel t1;
release channel t2;
}

allocate channel for maintenance device type disk;

delete copy completed before 'sysdate-1';
crosscheck archivelog all;
crosscheck backup;
delete noprompt force expired backup;
delete noprompt force expired archivelog all;
restore database validate;
validate archivelog all;
restore controlfile validate;

####    delete obsolete; (delete regarding Retention_policy)

release channel;...

Standby backup rcv file (same as primary db):

run {
allocate channel t1 device type disk;
allocate channel t2 device type disk;
backup as copy database;
backup archivelog all;
release channel t1;
release channel t2;
}

allocate channel for maintenance device type disk;

delete copy completed before 'sysdate-1';
crosscheck archivelog all;
crosscheck backup;
delete noprompt force expired backup;
delete noprompt force expired archivelog all;
restore database validate;
validate archivelog all;
restore controlfile validate;

####    delete obsolete;(delete regarding Retention_policy)

release channel;


Thursday 11 September 2014

Scripts to check backup status and timings of database backups



col STATUS format a9
col hrs format 999.99
 
select
SESSION_KEY, INPUT_TYPE, STATUS,
to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,
to_char(END_TIME,'mm/dd/yy hh24:mi')   end_time,
elapsed_seconds/3600                   hrs
from V$RMAN_BACKUP_JOB_DETAILS
order by session_key;
 
 
or can be restricted to report according to the concerned input_type :
 
 
col STATUS format a9
col hrs format 999.99
 
 
select SESSION_KEY, INPUT_TYPE, STATUS,
       to_char(START_TIME,'mm/dd/yy hh24:mi') start_time,
       to_char(END_TIME,'mm/dd/yy hh24:mi')   end_time,
       elapsed_seconds/3600 hrsfrom V$RMAN_BACKUP_JOB_DETAILS
       where input_type='DB INCR' order by session_key;
 
-- or 'DB FULL'