Preparation for recovery: a scenario

You can use the RECOVER utility to recover table spaces or index spaces.

Db2 can recover a page set by using an image copy or system-level backup, the recovery log, or both. The Db2 recovery log contains a record of all changes that are made to the page set. If Db2 fails, it can recover the page set by restoring the image copy or system-level backup and applying the log changes to it from the point of the image copy or system-level backup.

The Db2 catalog and directory page sets must be copied at least as frequently as the most critical user page sets. Moreover, you are responsible for periodically copying the tables in the communications database (CDB), the application registration table, the object registration table, and the resource limit facility (governor), or for maintaining the information that is necessary to re-create them. Plan your backup strategy accordingly.

The following backup scenario suggests how Db2 utilities might be used when taking object level backups with the COPY utility:

Imagine that you are the database administrator for DBASE1. Table space TSPACE1 in DBASE1 has been available all week. On Friday, a disk write operation for TSPACE1 fails. You need to recover the table space to the last consistent point before the failure occurred. You can do that because you have regularly followed a cycle of preparations for recovery. The most recent cycle began on Monday morning:

Monday morning

You start the DBASE1 database and make a full image copy of TSPACE1 and all indexes immediately. That gives you a starting point from which to recover. Use the COPY utility with the SHRLEVEL CHANGE option to improve availability.

Tuesday morning

You run the COPY utility again. This time you make an incremental image copy to record only the changes that have been made since the last full image copy that you took on Monday. You also make a full index copy.

TSPACE1 can be accessed and updated while the image copy is being made. For maximum efficiency, however, you schedule the image copies when online use is minimal.

Wednesday morning

You make another incremental image copy, and then create a full image copy by using the MERGECOPY utility to merge the incremental image copy with the full image copy.

Thursday and Friday mornings

You make another incremental image copy and a full index copy each morning.

Friday afternoon

An unsuccessful write operation occurs and you need to recover the table space. You run the RECOVER utility. The utility restores the table space from the full image copy that was made by MERGECOPY on Wednesday and the incremental image copies that were made on Thursday and Friday, and includes all changes that are made to the recovery log since Friday morning.

Later Friday afternoon

The RECOVER utility issues a message announcing that it has successfully recovered TSPACE1 to the current point in time.

This scenario is somewhat simplistic. You might not have taken daily incremental image copies on just the table space that failed. You might not ordinarily recover an entire table space. However, it illustrates this important point: with proper preparation, recovery from a failure is greatly simplified.