Pruning the recovery history file

The database manager creates entries in the recovery history file for events such as a backup operation, a restore operation, table space creation, and others. When an entry in the recovery history file is no longer relevant, because the associated recovery objects would no longer be needed to recover the database, you might want to remove, or prune, those entries from the recovery history file.

Procedure

You can prune the entries in the recovery history file using the following methods:

  • Invoke the PRUNE HISTORY command
  • Call the db2Prune API
  • Call the ADMIN_CMD procedure with the PRUNE_HISTORY parameter

What to do next

When you use one of these methods to prune the recovery history file, the database manager removes (prunes) entries from the recovery history file that are older than a timestamp you specify.

If a recovery history file entry matches the criteria you specify for pruning, but that entry would still be needed for a recovery of the database, the database manager will not prune the entry unless you use the WITH FORCE parameter or the DB2PRUNE_OPTION_FORCE flag.

If you use the AND DELETE parameter or the DB2PRUNE_OPTION_DELETE flag, then log files associated with pruned entries will be deleted as well.

If you set the AUTO_DEL_REC_OBJ database configuration parameter to ON, and you use the AND DELETE parameter or the DB2PRUNE_OPTION_DELETE flag, then log files, backup images, and load copy images associated with pruned entries will be deleted.

During pruning, the database manager runs two operations:
  1. The updating of the status of the recovery history file entries.
  2. The pruning of expired recovery history file entries.
The database manager updates the recovery history file entries in the following way:
  • All active database backup images that are no longer needed are marked as expired.
  • All database backup images that are marked as inactive and that were taken before the point at which an expired database backup was taken are also marked as expired. All associated inactive table space backup images and load backup copies are also marked as expired.
  • If an active database backup image is restored, but it is not the most recent database backup recorded in the history file, any subsequent database backup images belonging to the same log sequence are marked as inactive.
  • If an inactive database backup image is restored, any inactive database backups belonging to the current log sequence are marked as active again. All active database backup images that are no longer in the current log sequence are marked as inactive.
  • Any database or table space backup image that does not correspond to the current log sequence, also called the current log chain, is marked inactive. The current log sequence is determined by the database backup image that has been restored, and the log files that have been processed. Once a database backup image is restored, all subsequent database backup images become inactive, because the restored image begins a new log chain. This behavior is true if the backup image was restored without rolling forward. If a rollforward operation has occurred, all database backups that were taken after the break in the log chain are marked as inactive. It is conceivable that an older database backup image must be restored because the rollforward utility has gone through the log sequence containing a damaged current backup image.
  • A table space-level backup image becomes inactive if, after it is restored, the current state of the database cannot be reached by applying the current log sequence.
  • Any entries that have a status of do_not_delete are not pruned, and their associated log files, backup images, and load copy images are not deleted.
  • When a database is upgraded, all online database backup entries and all online or offline table space backup entries in the history file are marked as expired, so that these entries are not selected by automatic rebuild as images required for rebuilding. Load copy images and log archive entries are also marked as expired, since these types of entries cannot be used for recovery purposes