Rollforward overview

You cannot recover transactions that occurred after backup image creation by using the restore tools. Instead, you can recover transactions that have occurred since the last backup command was completed by using rollforward commands. You must enable database logging for these commands to be effective.

The simplest form of the ROLLFORWARD DATABASE command requires only that you specify the alias name of the database that you want to rollforward recover, as in the following example:
   db2 ROLLFORWARD DB sample

In IBM® Data Studio Version 3.1 or later, you can use the task assistant for rolling forward databases. Task assistants can guide you through the process of setting options, reviewing the automatically generated commands to perform the task, and running these commands. For more details, see Administering databases with task assistants.

The following is one approach you can use to perform rollforward recovery:
  1. Invoke the rollforward utility without the STOP option.
  2. Invoke the rollforward utility with the QUERY STATUS option

    If you specify recovery to the end of the logs, the QUERY STATUS option can indicate that one or more log files are missing, if the returned point in time is earlier than you expect.

    If you specify point-in-time recovery, the QUERY STATUS option helps you to ensure that the rollforward operation completes at the correct point.

  3. Invoke the rollforward utility with the STOP option. After the operation stops, it is not possible to roll additional changes forward.
An alternate approach you can use to perform rollforward recovery is the following:
  1. Invoke the rollforward utility with the AND STOP option.
  2. The need to take further steps depends on the outcome of the rollforward operation:
    • If it is successful, the rollforward is complete and the database is connectable and usable. At this point, it is not possible to roll additional changes forward.
    • If any errors were returned, take whatever action is required to fix the problem. For example, if there is a missing log file: find the log file, or if there are retrieve errors: ensure that log archiving is working. Then reissue the rollforward utility with the AND STOP option.

A database must be restored successfully (using the restore utility) before it can be rolled forward, but a table space does not. A table space can be temporarily put in rollforward pending state, but not require a restore operation to undo it (following a power interruption, for example).

When the rollforward utility is invoked:
  • If the database is in rollforward pending state, the database is rolled forward. Any table spaces that were restored from backup images that were taken after the database backup image, and are currently in rollforward pending state are also rolled forward. Any table spaces that were taken prior to the database level backup and restored after the database level backup was restored remain in rollforward pending state. You must issue a subsequent table space level rollforward to recover them.

  • If the database is not in rollforward pending state, but table spaces in the database are in rollforward pending state:
    • If you specify a list of table spaces, only those table spaces are rolled forward.
    • If you do not specify a list of table spaces, all table spaces that are in rollforward pending state are rolled forward.

A database rollforward operation runs offline. The database is not available for use until the rollforward operation completes successfully, and the operation cannot complete unless the STOP option was specified when the utility was invoked.

A table space rollforward operation can run offline. The database is not available for use until the rollforward operation completes successfully. This occurs if the end of the logs is reached, or if the STOP option was specified when the utility was invoked.

You can perform an online rollforward operation on table spaces, as long as SYSCATSPACE is not included. When you perform an online rollforward operation on a table space, the table space is not available for use, but the other table spaces in the database are available.

When you first create a database, it is enabled for circular logging only. This means that logs are reused, rather than being saved or archived. With circular logging, rollforward recovery is not possible: only crash recovery or version recovery can be done. Archived logs document changes to a database that occur after a backup was taken. You enable log archiving (and rollforward recovery) by setting the logarchmeth1 database configuration parameter to a value other than its default of OFF. When you set logarchmeth1 to a value other than OFF, the database is placed in backup pending state, and you must take an offline backup of the database before it can be used again.
Note: Entries are made in the recovery history file for each log file that is used in a rollforward operation.
In this example, the command returns:
In a partitioned database environment and a Db2® pureScale® environment, this status information is returned for each database partition or member:
db2 rollforward db mydb to end of logs

                                 Rollforward Status

 Input database alias                   = mydb
 Number of members have returned status = 3

 Member ID Rollforward   Next log      Log files processed        Last committed transaction
           status        to be read
 --------- ------------  ------------  -------------------------  --------------------------
         0  DB  working  S0000001.LOG  S0000000.LOG-S0000000.LOG  2009-05-06-15.28.11.000000 UTC
         1  DB  working  S0000010.LOG  S0000000.LOG-S0000009.LOG  2009-05-06-15.28.20.000000 UTC
         2  DB  working  S0000005.LOG  S0000000.LOG-S0000004.LOG  2009-05-06-15.27.33.000000 UTC

DB20000I  The ROLLFORWARD command completed successfully.