Pavan DBA's Blog

The DBA Knowledge Store

What happens during HOT BACKUP???

Posted by Pavan DBA on April 23, 2012


I am just trying to explain my little knowledge on hot backup process…

During hot backup, a script or begin backup command puts a tablespace into backup mode, then copies the datafiles to disk or tape, then takes the tablespace out of backup mode.

Many people are having a misconception regarding hot backup that, during hot backup DBWR process will stop writing into datafiles. Also, they say that while the datafiles are not writable, changes are stored somewhere in the SGA, the redologs, the rollback segments etc places and will be written back to datafiles when the tablespace is taken out of backup mode.

In fact, Oracle’s tablespace hot backup does not work this way at all. It absolutely does not stop writing the datafiles, and actually allows continued operation of the database almost exactly as during normal operation.

1. The tablespace is checkpointed 2. The checkpoint SCN in the datafile header freeze to increment with checkpoints 3. Full images of changed DB blocks are written to the redologs

The above three actions are all that is required to guarantee consistency once the file is restored and recovery is applied. By freezing the checkpoint SCN in the file headers, any subsequent recovery on that backup copy of the file will know that it must commence at that SCN. Having an old SCN in the file header tells recovery that the file is an old one, and that it should look for the redolog file containing that SCN, and apply recovery starting there. Note that checkpoints to datafiles in hot backup mode are not stopped during the backup, only the incrementing of the main checkpoint SCN flag will stop increasing.

By initially checkpointing the datafiles that comprise the tablespace and logging full block images to redo, Oracle guarantees that any blocks changed in the datafile while in hot backup mode will also be available in the redologs in case they are ever used for a recovery.

Also we will observe that huge redo will be generated during hot backup. This is the result of the logging of full images of changed blocks in these tablespaces to the redologs. Normally, Oracle logs an entry in the redologs for every change in the database, but it does not log the whole image of the database block. By logging full images of changed DB blocks to the redologs during backup mode, Oracle eliminates the possibility of the backup containing fractured blocks. To understand this reasoning, you must first understand what a fractured block is….

Typically, Oracle database blocks are a multiple of O/S blocks. For instance, most Unix filesystems have a default block size of 4k, while Oracle’s default block size is 8k. This means that the filesystem stores data in 4k chunks, while Oracle performs reads and writes in 8k chunks, or multiples. While backing up a datafile, your backup script makes a copy of the datafile from the filesystem, using O/S utilities such as copy, dd etc. As it is making this copy, it is reading in O/S-block sized increments. If the database writer happens to be writing a DB block into the datafile at the same time when backup is reading that block, your backup copy of the DB block could contain some O/S blocks before and after writing by DBWR. This kind of blocks which are having mismatched halves are called fractured blocks.

By logging the full block image of the changed block to the redologs, it guarantees that in the event of a recovery, any fractured that might be in the backup copy of the datafile will be resolved by replacing them with the full image of the block from the redologs.

24 Responses to “What happens during HOT BACKUP???”

  1. mubarak said

    Good Article.

    During hot backup , some peoples are taking only data files and some others are takinhg data files and control files.

    1 ) Taking control file backup for hot backup – is it right method ?

    2) If control backup physically not required means , how can we restore control files ? ( LOST OF ALL CONTROL FILES)

    Thanks

  2. Rajkumar said

    hi pavan it is so good explanation..

  3. Venkatesh said

    1) while in begin backup mode, suppose one of user inserting 1000 rows in that table & executing commit command. So what happen in this case? whether these data will be inserted to datafiles or not?
    2) If yes, can other users retrieve the new data?

  4. Shihab said

    In case of fractured blocks since full block is in redo logs, incompleted recovery is possible?

  5. Owais Rashid said

    Can you please share a link to some videos on which we can see how realtime patching, user management, cloning wtc are done

  6. jagadeesh said

    very nice explanation sir….

  7. rajucpatilshekar Patil said

    Dear Sir,
    Above document was good and helped me a lot.
    I have one Querry i,e i am working in a medical domain as ORACLE DBA and want to switch to MNC’s there will be any problem in switching.

    Regards
    Rajshekar Patil

  8. muralidharan said

    many thanks very nice explaination…

  9. vamsi reddy said

    Note that checkpoints to datafiles in hot backup mode are not stopped during the backup, only the incrementing of the main checkpoint SCN flag will stop increasing.

    Good information, i have a doubt about incremental checkpoint( incrementing main checkpoint) ?

    • Pavan DBA said

      yes please tell me…

      • Mandy said

        Hi Pavan,

        I have two questions.

        1) You said that the increment of SCN on datafile header will freeze. May I know when the increment of SCN will unfreeze? and will it be the header be updated with new SCN numbers and why ?

        2) Is the fractured block only reason why we are keeping two copied of data – once is online redo log file and another in datafile ?

        Thanks & Regards,

        Mandy

      • Pavan DBA said

        1. once we give end backup command, then header will unfreeze and SCN will get updated. if SCN is not updated, then it means datafile is not at latest timestamp and will create issues. that is why always oracle make sures that all datafiles are in same SCN.

        2. yes

      • Mandy said

        Hi Pavan,

        One more please,

        question) When we take backup using rman is that considered a hot or cold backup?

        Thanks,

        Mandy

      • Pavan DBA said

        it depends on how u r taking. in rman also we can take cold backup or hot backup. if u place db in mount state and taking rman backup it is considered as cold bkp. if u r dng when db is open, it is rman hot bkp

  10. Naveen R Kottur said

    Indeed it helped me in understanding the fractured blocks

  11. Rajesh Darla said

    Good one! Nice explanation ..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: