Incrementally Updated Backup In 10G and higher (文档 ID 303861.1)

***Checked for relevance on 25-Oct-2013*** 

PURPOSE 
------------ 

To use the new Incremental merge backup feature in oracle 10G which helps in 
reducing the mean time to recover database. 


SCOPE & APPLICATION
---------------------------

DBAs, anyone interested in learning this new feature.


INCREMENTAL MERGE BACKUP :
---------------------------

Based on the concept that disk technology are getting cheaper, more disks can be used
for backup purposes. Oracle has introduced a new concept, in which RMAN
takes an image copy of database as a base backup and as subsequent 
incremental backups are taken, they are applied (recovered) on the image copies. 

This new feature allows incremental backups to be applied on base image copy 
on the fly.  I.e., each incremental backup cycle will roll forward 
the database image copy to later moment in time. Thus when there is a need to 
do restore and recover, there is an updated image copy of the database is 
available on disk.

If MTTR is a constraint then SWITCH DATABASE TO COPY can be used to switch the 
datafiles to the updated image copy available and there is no need to restore.  
Even if the database is restored, fewer archive log files will be needed to 
roll forward the database.  For example, less than 24 hours of archivelog files 
will be needed if the latest incremental is applied on a daily bases.  This is 
the Oracle Suggested Backup Strategy.   

One limitation in using Incremental merge backups is that more disk space 
will be needed as a full image copy of the database will reside in the backup 
location.  Another limit is that point in time recovery of the database cannot 
be performed before the last application of the incremental backup.  For example, 
24 hours if the backup is already roll forwarded by last incremental backup.  
This limitation depends upon how one schedules incremental backups and its 
application on the image copy backups. 

Few consideration :

1) At any given time what is fall back duration?  I.e., until which time 
will it be needed to perform incomplete recovery on the database.

2) Depending upon the time needed for fall back there will be need of more disk space.

3) If a retention policy other than default (redundancy=1) is needed, further 
steps may be necessary beyond the generic use of this feature.  See Note:351455.1.

SYNTAX
======

With this Incremental Merge approach, the daily RMAN incremental backup 
script will look like :

RMAN>  BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY 
WITH TAG WEEKLY DATABASE;

RMAN>  RECOVER COPY OF DATABASE WITH TAG WEEKLY;

When this command is executed every day, the incremental backups are applied 
to the Level 0 backup with the tag WEEKLY. Each incremental backup is merged 
with the current full backup, making it a complete up-to-date backup as of 
that day. 

EXAMPLE
=======

Day 1 - SUNDAY
==============

The first time this script runs, it creates the level 0 backup of the datafiles 
needed to begin the cycle of incremental updates.

Since Sunday is the first Incremental Merge Backup RMAN will take a level 0 
backup of all the datafiles.

RMAN> BACKUP INCREMENTAL LEVEL 1
FOR RECOVER OF COPY
WITH TAG WEEKLY DATABASE;

Starting backup at 20-MAR-05
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=125 devtype=DISK
no parent backup or copy of datafile 3 found ## Since this is the First backup ##
no parent backup or copy of datafile 1 found
no parent backup or copy of datafile 2 found
no parent backup or copy of datafile 4 found
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSAUX01.DBF
output filename=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-1366687711_TS-SYSAUX_FNO-3_04GG97NU tag=WEEKLY recid=1 stamp=553951096
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:08
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSTEM01.DBF
output filename=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-1366687711_TS-SYSTEM_FNO-1_05GG97S0 tag=WEEKLY recid=2 stamp=553951227
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:07
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\UNDOTBS01.DBF
output filename=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-1366687711_TS-UNDOTBS1_FNO-2_06GG9801 tag=WEEKLY recid=3 stamp=553951286
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:58
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\USERS01.DBF
output filename=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-1366687711_TS-USERS_FNO-4_07GG981R tag=WEEKLY recid=4 stamp=553951323
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:37
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 20-MAR-05
channel ORA_DISK_1: finished piece 1 at 20-MAR-05
piece handle=C:\WINNT\SYSTEM32\08GG9830_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36
Finished backup at 20-MAR-05

/* The above creates an image copy of all the datafiles, these can be seen using 
the RMAN command 'list copy of database;' */

The 'RECOVER COPY OF DATABASE WITH TAG...' command instructs RMAN to apply any 
incremental level 1 backups to a set of datafile copies with the same tag.  
At this time, there is no incremental backup to apply, so the command generates 
a message.

RMAN> RECOVER COPY OF DATABASE WITH TAG WEEKLY;

Starting recover at 20-MAR-05
using channel ORA_DISK_1
no copy of datafile 1 found to recover
no copy of datafile 2 found to recover
no copy of datafile 3 found to recover
no copy of datafile 4 found to recover
Finished recover at 20-MAR-05

Day 2 - MONDAY
===============

In the second run and all subsequent runs, RMAN produces a level 1 incremental 
backup of the datafiles:

RMAN> BACKUP INCREMENTAL LEVEL 1
FOR RECOVER OF COPY
WITH TAG WEEKLY DATABASE;

Starting backup at 21-MAR-05
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=119 devtype=DISK
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00003 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSAUX01.DBF
input datafile fno=00001 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSTEM01.DBF
input datafile fno=00002 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\UNDOTBS01.DBF
input datafile fno=00004 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 21-MAR-05
channel ORA_DISK_1: finished piece 1 at 21-MAR-05
piece handle=C:\WINNT\SYSTEM32\09GGBSSP_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:39
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 21-MAR-05
channel ORA_DISK_1: finished piece 1 at 21-MAR-05
piece handle=C:\WINNT\SYSTEM32\0AGGBSU0_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:32
Finished backup at 21-MAR-05

The 'RECOVER COPY OF DATABASE WITH TAG..' command causes RMAN to apply Monday's
incremental level 1 backups to the set of datafile copies with the tag 
WEEKLY taken on SUNDAY.

RMAN> RECOVER COPY OF DATABASE WITH TAG WEEKLY;

Starting recover at 21-MAR-05
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafilecopy fno=00001 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-SYSTEM_FNO-1_05GG97S0
recovering datafilecopy fno=00002 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-UNDOTBS1_FNO-2_06GG9801
recovering datafilecopy fno=00003 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-SYSAUX_FNO-3_04GG97NU
recovering datafilecopy fno=00004 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-USERS_FNO-4_07GG981R
channel ORA_DISK_1: restored backup piece 1
piece handle=C:\WINNT\SYSTEM32\09GGBSSP_1_1 tag=TAG20050327T112928
channel ORA_DISK_1: restore complete
Finished recover at 21-MAR-05

******************************************************************************
Here the recover command applies the incremental backup on Image copy and thus 
rolling forwarded image copy of database to time of backup.  If there is a need to 
fall back to a time in the past, it can not be done as there is no datafile 
backup old enough available to restore.  

This Incremental backup application can be delayed to achieve a larger  
fall back window using commands like:

RECOVER COPY OF DATABASE WITH TAG WEEKLY until time 'sysdate-1' OR
RECOVER COPY OF DATABASE WITH TAG WEEKLY until time 'sysdate-2'

******************************************************************************

Day 3 - TUESDAY
================

On Tuesday, the DBA added a new tablespace to the database .

SQL> create tablespace AMAR datafile 'D:\ORACLE\PRODUCT\ORADATA\AMAR\AMAR01.dbf'
size 2M;

Tablespace created.

/* Current level 0 backup does not have an image copy of the newly created datafile 
for the AMAR tablespace.  The next RMAN backup will create the image copy of 
the datafile belonging to this tablespace and will take incremental backup for 
other datafiles: */

RMAN> BACKUP INCREMENTAL LEVEL 1
2> FOR RECOVER OF COPY
3> WITH TAG WEEKLY DATABASE;

Starting backup at 22-MAR-05
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=120 devtype=DISK
no parent backup or copy of datafile 5 found
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00003 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSAUX01.DBF
input datafile fno=00001 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSTEM01.DBF
input datafile fno=00002 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\UNDOTBS01.DBF
input datafile fno=00004 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 22-MAR-05
channel ORA_DISK_1: finished piece 1 at 22-MAR-05
piece handle=C:\WINNT\SYSTEM32\0DGGH8E7_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:23
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\TEST01.DBF  <===========> file copy for new datafile.
output filename=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-1366687711_TS-AMAR_FNO-5_0EGGH8G
R tag=WEEKLY recid=13 stamp=554213958
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:48
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 22-MAR-05
channel ORA_DISK_1: finished piece 1 at 22-MAR-05
piece handle=C:\WINNT\SYSTEM32\0FGGH8IC_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
Finished backup at 22-MAR-05

/* The 'RECOVER COPY OF DATABASE WITH TAG..' command causes RMAN to apply 
Tuesday's incremental, level 1 backups on the previous updated backup as of 
Monday making it a complete up-to-date backup as of the Tuesday backup.  
However, for datafile AMAR01.DBF its a newly created image copy so no update 
is required. */

RMAN> RECOVER COPY OF DATABASE WITH TAG WEEKLY;

Starting recover at 22-MAR-05
using channel ORA_DISK_1
no copy of datafile 5 found to recover
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafilecopy fno=00001 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-SYSTEM_FNO-1_05GG97S0
recovering datafilecopy fno=00002 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-UNDOTBS1_FNO-2_06GG9801
recovering datafilecopy fno=00003 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-SYSAUX_FNO-3_04GG97NU
recovering datafilecopy fno=00004 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-USERS_FNO-4_07GG981R
channel ORA_DISK_1: restored backup piece 1
piece handle=C:\WINNT\SYSTEM32\0DGGH8E7_1_1 tag=TAG20050329T121705
channel ORA_DISK_1: restore complete
Finished recover at 22-MAR-05

/* The incremental backup is applied on all datafiles except the newly added
datafile.*/

DAY 4 - WEDNESDAY
=================

RMAN> BACKUP INCREMENTAL LEVEL 1
FOR RECOVER OF COPY
WITH TAG WEEKLY DATABASE;

Starting backup at 23-MAR-05
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00003 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSAUX01.DBF
input datafile fno=00001 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSTEM01.DBF
input datafile fno=00002 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\UNDOTBS01.DBF
input datafile fno=00004 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\USERS01.DBF
input datafile fno=00005 name=D:\ORACLE\PRODUCT\ORADATA\AMAR\AMAR01.DBF
channel ORA_DISK_1: starting piece 1 at 23-MAR-05
channel ORA_DISK_1: finished piece 1 at 23-MAR-05
piece handle=C:\WINNT\SYSTEM32\0GGGJTHG_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:51
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 23-MAR-05
channel ORA_DISK_1: finished piece 1 at 23-MAR-05
piece handle=C:\WINNT\SYSTEM32\0HGGJTJ3_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:26
Finished backup at 23-MAR-05

RMAN> RECOVER COPY OF DATABASE WITH TAG WEEKLY;

Starting recover at 30-MAR-05
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafilecopy fno=00001 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-SYSTEM_FNO-1_05GG97S0
recovering datafilecopy fno=00002 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-UNDOTBS1_FNO-2_06GG9801
recovering datafilecopy fno=00003 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-SYSAUX_FNO-3_04GG97NU
recovering datafilecopy fno=00004 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-USERS_FNO-4_07GG981R
recovering datafilecopy fno=00005 name=C:\WINNT\SYSTEM32\DATA_D-AMAR_I-136668771
1_TS-AMAR_FNO-5_0EGGH8GR
channel ORA_DISK_1: restored backup piece 1
piece handle=C:\WINNT\SYSTEM32\0GGGJTHG_1_1 tag=TAG20050330T122933
channel ORA_DISK_1: restore complete
Finished recover at 23-MAR-05

/* The Incremental applied on all datafiles, including the added datafile */

DAY 5 - THURSDAY
================

The database crashes and all datafiles are lost?
................................................

## Database crashed ##
SQL> startup
ORACLE instance started.

Total System Global Area 121634816 bytes
Fixed Size 787748 bytes
Variable Size 95419100 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: 'D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSTEM01.DBF'

Resolution :
.............

The DBA will restore the INCREMENTAL MERGE backup as of Wednesday 
and apply all the archivelogs generated since the backup to recover the database.

RMAN> restore database;

Starting restore at 24-MAR-05
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK

channel ORA_DISK_1: restoring datafile 00001
input datafilecopy recid=21 stamp=554301135 filename=C:\WINNT\SYSTEM32\DATA_D-AM
AR_I-1366687711_TS-SYSTEM_FNO-1_05GG97S0
destination for restore of datafile 00001: D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSTEM01.DBF
channel ORA_DISK_1: copied datafilecopy of datafile 00001
output filename=D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSTEM01.DBF recid=23 stamp=554301601
channel ORA_DISK_1: restoring datafile 00002
input datafilecopy recid=20 stamp=554301129 filename=C:\WINNT\SYSTEM32\DATA_D-AM
AR_I-1366687711_TS-UNDOTBS1_FNO-2_06GG9801
destination for restore of datafile 00002: D:\ORACLE\PRODUCT\ORADATA\AMAR\UNDOTBS01.DBF
channel ORA_DISK_1: copied datafilecopy of datafile 00002
output filename=D:\ORACLE\PRODUCT\ORADATA\AMAR\UNDOTBS01.DBF recid=24 stamp=554301617
channel ORA_DISK_1: restoring datafile 00003
input datafilecopy recid=22 stamp=554301142 filename=C:\WINNT\SYSTEM32\DATA_D-AM
AR_I-1366687711_TS-SYSAUX_FNO-3_04GG97NU
destination for restore of datafile 00003: D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSAUX01.DBF
channel ORA_DISK_1: copied datafilecopy of datafile 00003
output filename=D:\ORACLE\PRODUCT\ORADATA\AMAR\SYSAUX01.DBF recid=25 stamp=554301673
channel ORA_DISK_1: restoring datafile 00004
input datafilecopy recid=18 stamp=554301120 filename=C:\WINNT\SYSTEM32\DATA_D-AM
AR_I-1366687711_TS-USERS_FNO-4_07GG981R
destination for restore of datafile 00004: D:\ORACLE\PRODUCT\ORADATA\AMAR\USERS01.DBF
channel ORA_DISK_1: copied datafilecopy of datafile 00004
output filename=D:\ORACLE\PRODUCT\ORADATA\AMAR\USERS01.DBF recid=26 stamp=554301680
channel ORA_DISK_1: restoring datafile 00005
input datafilecopy recid=19 stamp=554301124 filename=C:\WINNT\SYSTEM32\DATA_D-AM
AR_I-1366687711_TS-AMAR_FNO-5_0EGGH8GR
destination for restore of datafile 00005: D:\ORACLE\PRODUCT\ORADATA\AMAR\AMAR01.DBF
channel ORA_DISK_1: copied datafilecopy of datafile 00005
output filename=D:\ORACLE\PRODUCT\ORADATA\AMAR\AMAR01.DBF recid=27 stamp=554301683
Finished restore at 24-MAR-05

******************************************************************************
/* To Save time in restore one can use Switch database to copy command 

RMAN> switch database to copy;

All datafiles pointers will be pointed to image backup copy. */
******************************************************************************

RMAN> recover database;

Starting recover at 24-MAR-05
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 690 is already on disk as file D:\ORACLE\PRODUCT\A
DMIN\AMAR\ARCH1\ARC00690_0552309312.001
archive log thread 1 sequence 691 is already on disk as file D:\ORACLE\PRODUCT\A
DMIN\AMAR\ARCH1\ARC00691_0552309312.001
archive log thread 1 sequence 692 is already on disk as file D:\ORACLE\PRODUCT\A
DMIN\AMAR\ARCH1\ARC00692_0552309312.001
archive log filename=D:\ORACLE\PRODUCT\ADMIN\AMAR\ARCH1\ARC00690_0552309312.001
thread=1 sequence=690
archive log filename=D:\ORACLE\PRODUCT\ADMIN\AMAR\ARCH1\ARC00691_0552309312.001
thread=1 sequence=691
media recovery complete
Finished recover at 24-MAR-05

RMAN> alter database open;

database opened

/* The database is recovered much faster than the traditional method of recovery. */

TRADITIONAL APPROACH
--------------------

Lets compare the necessary steps to bring back the database with traditional 
approach vs incremental merge approach:

1  Restore database:
   Traditional:  Restore the level 0 backup taken on Sunday.
   Inc Merge:    Restore complete backup saved as of Wednesday.  This 
                 step can be skipped with the 'switch database' command.

2  Recover database:
   Traditional:  Apply all incremental backups starting from Monday 
   Inc Merge:    NO INCREMENTAL BACKUP to APPLY, already applied as of Wednesday.

3  Media Recovery:
   Traditional:  Apply all Archivelogs since incremental backup  
   Inc Merge :   Apply all Archivelogs since incremental backup  


Steps 1 and 2 are entirely eliminated with the INCREMENTAL MERGE (and switch
database) approach.  This reduces the time needed to restore and recover the 
database. 

Step 2 is entirely eliminated with the INCREMENTAL MERGE if database is 
restored. 

RELATED DOCUMENTS 
---------------------------- 

Oracle 10g Backup & Recovery Advanced User Guide 
Oracle 10g Database 2 Day DBA guide 
Note:351455.1 Oracle Suggested Strategy & Backup Retention

--------------------------------------------------------------------------------

REFERENCES

NOTE:351455.1 - Oracle Suggested Strategy & Backup Retention
 
 

相关内容

   
 
 

产品

   
 
  • Oracle Database Products > Oracle Database > Oracle Database > Oracle Database - Enterprise Edition > Recovery Manager > Recovery command
 

错误

   
 
ORA-1110; ORA-1157

你可能感兴趣的:(Incrementally Updated Backup In 10G and higher (文档 ID 303861.1))