Administration Guide

Garbage Collection

The number of DB2 database backups documented in the Recovery History File is monitored automatically by something called "DB2 Garbage Collection". The configuration parameter num_db_backups defines how many "active" backups are kept. An active backup is one that can be restored and rolled forward using the current logs to reach the current state of the database. An "inactive" backup cannot be restored and rolled forward to reach the current state of the database because it requires a different set of log files.

Each of the examples shown in the artwork that follows makes the assumption that num_db_backups has been set to four.

Figure 60. Active Database Backups


Active Database Backups

All database backups that are no longer needed are marked as "expired". These backups are considered no longer needed because there are several database backups as defined by num_db_backups that are more recent. All table space backups and load backup copies that were taken before the database backup expired are also marked as "expired".

Figure 61. Expired Database Backups


Expired Database Backups

All database backups that are marked as "inactive" and were taken previous to the point in time when the expired database backup was taken are also marked as "expired". All associated "inactive" table space backups and load backup copies are also marked as "expired".

When DATALINK columns are involved with the backups as described in the next section, all Data Links servers running the DB2 Data Links Manager are contacted to request the garbage collection of the associated Data Links server files unlinked before the backup that has expired. After physically deleting these backups based on the information contained in the history file, you can use the PRUNE HISTORY command to remove "expired" entries from the history file. If you do not explicitly prune the history file, the next database backup will cause the "expired" entries to be pruned automatically.

DB2 Garbage Collection also is responsible for marking the history file entries for a DB2 database or table space backup as "inactive" if that backup does not correspond to the current log sequence also called the current log chain. The current log sequence is determined by the DB2 database backup that has been restored and the log files that have been processed. Once a database backup is restored, all database backups that were taken after the backup that was restored become "inactive", since the restored backup begins a new log chain. A table space backup becomes "inactive" when, after restoring it, the current state of the DB2 database cannot be reached by applying the current sequence of logs. (When a DB2 database or table space backup becomes "inactive", DB2 Garbage Collection notifies all Data Links servers running DB2 Data Links Manager so that the corresponding set of file backups would also be marked as "inactive".)

Figure 62. Active Database Backups


Active Database Backups

Figure 63. Inactive Database Backups


Inactive Database Backups

DB2 Garbage Collection is invoked after completing a DB2 database backup. The value of the db2_num_backups configuration parameter is used to scan the current history file starting with the last entry.

DB2 Garbage Collection is also invoked after completing a restore of a database backup with or without rolling forward the logs.

If an "active" database backup is restored, but it is not the most recent database backup recorded in the history file, any subsequent database backups belonging to the same log sequence are marked as "inactive".

If an "inactive" database backup is restored, any inactive database backups belonging to the current log sequence are marked as "active" again. As with restoring an "active" database backup, all active database backups that are no longer in the current log sequence are marked as "inactive".

If DATALINK columns are part of the database backups being performed, DB2 Garbage Collection then contacts all Data Links servers running the DB2 Data Links Manager to make the same status changes to the corresponding set of file backups on the Data Links servers.

After every full database backup, the rec_his_retentn configuration parameter is used to prune "expired" entries from the history file. All "expired" backups are removed.

The PRUNE HISTORY command can be used by you at any time to prune only backups marked as "expired" from the history file unless the WITH FORCE option is used. (If a backup is pruned that is not "expired", all Data Links servers are contacted and requested to flag for garbage collection the corresponding set of file backups.)

Figure 64. Mixed Active, Inactive, and Expired Database Backups


Mixed Active, Inactive, and Expired Database Backups

Figure 65. Expired Log Sequence


Expired Log Sequence


[ Top of Page | Previous Page | Next Page ]