What Happens When A Tablespace/Database Is Kept In Begin Backup Mode (Doc ID 469950.1), tablespace469950.1
Goal
This document explains in detail about what happens when a tablespace/datafile is kept in hot backup/begin backup mode.
Solution
To performOnline/hot backupWe have to put the tablespace in begin backup mode followed by copying the datafiles and then putting the tablespace to end backup.
In 8i, 9i we have to put each tablespace individually in begin/end backup mode to perform the online backup. From 10g onwards the entire database can be put in begin/end backup mode.
Make sure that the database is in archivelog mode
Example:
Discovery a single tablespace backup
+ SQL> alter tablespace system begin backup;
+ Copy the corresponding datafiles using appropriate O/S commands.
+ SQL> alter tablespace system end backup;
Discovery a full database backup (starting from 10g)
+ SQL> alter database begin backup;
+ Copy all the datafiles using appropriate O/S commands.
+ SQL> alter database end backup;
One danger in making online backups is the possibility of inconsistent data within a block. for example, assume that you are backing up block 100 in datafile users. dbf. also, assume that the copy utility reads the entire block while DBWR is in the middle of updating the block. in this case, the copy utility may read the old data in the top half of the block and the new data in the bottom top half of the block. the result is called a fractured block, meaning that the data contained in this block is not consistent. at a given SCN.
Therefore oracle internally manages the consistency as below:
1. the first time a block is changed in a datafile that is in hot backup mode, the entire block is written to the redo log files, not just the changed bytes. normally only the changed bytes (a redo vector) is written. in hot backup mode, the entire block is logged the first time. this is because you can get into a situation where the process copying the datafile and DBWR are working on the same block simultaneously.
Lets say they are and the OS blocking read factor is 512 bytes (the OS reads 512 bytes from disk at a time ). the backup program goes to read an 8 k Oracle block. the OS gives it 4 k. meanwhile -- DBWR has asked to rewrite this block. the OS schedules the DBWR write to occur right now. the entire 8 k block is rewritten. the backup program starts running again (multi-tasking OS here) and reads the last 4 k of the block. the backup program has now gotten an fractured block -- the head and tail are from two points in time.
We cannot deal with that during recovery. hence, we log the entire block image so that during recovery, this block is totally rewritten from redo and is consistent with itself atleast. we can recover it from there.
2. the datafile headers which contain the SCN of the last completed checkpoint are not updated while a file is in hot backup mode. this lets the recovery process understand what archive redo log files might be needed to fully recover this file.
To limit the effect of this additional logging, you shocould ensure you only place one tablepspace at a time in backup mode and bring the tablespace out of backup mode as soon as you have backed it up. this will reduce the number of blocks that may have to be logged to the minimum possible.
Try to take the hot/online backups when there is less/no load on the database, so less redo will be generated.