Restoring from incremental backup images

A restore operation from incremental backup images consists of four steps.

About this task

  1. Identifying the incremental target image.

    Determine the final image to be restored, and request an incremental restore operation from the Db2® restore utility. This image is known as the target image of the incremental restore, because it is the last image to be restored. The incremental target image is specified using the TAKEN AT parameter in the RESTORE DATABASE command.

  2. Restoring the most recent full database or table space image to establish a baseline against which each of the subsequent incremental backup images can be applied.
  3. Restoring each of the required full or table space incremental backup images, in the order in which they were produced, on top of the baseline image restored in Step 2.
  4. Repeating Step 3 until the target image from Step 1 is read a second time. The target image is accessed twice during a complete incremental restore operation. During the first access, only initial data is read from the image; none of the user data is read. The complete image is read and processed only during the second access.

    The target image of the incremental restore operation must be accessed twice to ensure that the database is initially configured with the correct history, database configuration, and table space definitions for the database that is created during the restore operation. In cases where a table space was dropped since the initial full database backup image was taken, the table space data for that image is read from the backup images but ignored during incremental restore processing.

There are two ways to restore incremental backup images: automatic and manual:
  • For an automatic incremental restore, the RESTORE DATABASE command is issued only once specifying the target image to be used. Db2 then uses the database history to determine the remaining required backup images and restores them.
  • For a manual incremental restore, the RESTORE DATABASE command must be issued once for each backup image that needs to be restored (as outlined in the steps listed previously).

Procedure

  • To restore a set of incremental backup images using automatic incremental restore, issue the RESTORE DATABASE command specifying time stamp of the last image you want to restore with the TAKEN AT parameter, as follows:
      db2 restore db sample incremental automatic taken at timestamp

    This results in the restore utility performing each of the steps described at the beginning of this section automatically. During the initial phase of processing, the backup image with the specified time stamp (specified in the form yyyymmddhhmmss) is read, and the restore utility verifies that the database, its history, and the table space definitions exist and are valid.

    During the second phase of processing, the database history is queried to build a chain of backup images required to perform the requested restore operation. If, for some reason this is not possible, and Db2 is unable to build a complete chain of required images, the restore operation terminates, and an error message is returned. In this case, an automatic incremental restore is not possible, and you must issue the RESTORE DATABASE command with the INCREMENTAL ABORT parameter. This will clean up any remaining resources so that you can proceed with a manual incremental restore.

    Note: It is highly recommended that you not use the WITH FORCE OPTION of the PRUNE HISTORY command. The default operation of this command prevents you from deleting history entries that might be required for recovery from the most recent, full database backup image, but with the WITH FORCE OPTION, it is possible to delete entries that are required for an automatic restore operation.

    During the third phase of processing, Db2 restores each of the remaining backup images in the generated chain. If an error occurs during this phase, you must issue the RESTORE DATABASE command with the INCREMENTAL ABORT option to clean up any remaining resources. You must then determine whether the error can be resolved before you reissue the RESTORE DATABASE command or attempt the manual incremental restore again.

  • To restore a set of incremental backup images, using manual incremental restore, issue RESTORE DATABASE commands specifying time stamp of each image you want to restore with the TAKEN AT parameter, as follows:
    1. db2 restore database dbname incremental taken at timestamp
      
      where timestamp points to the last incremental backup image (the target image) to be restored.
    2. db2 restore database dbname incremental taken at timestamp1
      
      where timestamp1 points to the initial full database (or table space) image.
    3. db2 restore database dbname incremental taken at timestampX
      
      where timestampX points to each incremental backup image in creation sequence.
    4. Repeat Step 3, restoring each incremental backup image up to and including image timestamp.

    If you are performing a database restore operation, and table space backup images have been produced, the table space images must be restored in the chronological order of their backup time stamps.

    The db2ckrst utility can be used to query the database history and generate a list of backup image time stamps needed for an incremental restore. A simplified restore syntax for a manual incremental restore is also generated. It is recommended that you keep a complete record of backups, and use this utility only as a guide.