Using rollforward
Use the ROLLFORWARD DATABASE command to apply transactions that were recorded in the database log files to a restored database backup image or table space backup image.
Before you begin
You can perform a database rollforward recovery or a table space rollforward recovery. If the
database is in roll forward pending state, you need to perform a database rollforward recovery. You
can confirm if the database is in roll forward pending state by connecting to the database and
seeing whether SQL1117N is returned.
If you are performing table space rollforward recovery, determine which table spaces you want to recover by checking the table space state. You can recover all table spaces in one rollforward recovery by issuing the ROLLFORWARD command without specifying a list of table spaces. Db2 will automatically perform the recovery on all the table spaces in roll forward pending state. You can recover a subset of table spaces by issuing the ROLLFORWARD command with a list of table spaces you want to recover. Recovering a subset of the table spaces instead of all table spaces can make the data in these table spaces available faster.
Once you start the table space rollforward operation with a list of table spaces, you must
complete the operation. You cannot change the list of table spaces on a subsequent
ROLLFORWARD command. If the subsequent ROLLFORWARD command
contains a table space that is not in the original list, the command fails with
SQL4908N. If the subsequent ROLLFORWARD command has less table
spaces than the original command, those table spaces not included are put into restore pending state
which means these table spaces must be restored again. This increases the time required to complete
the recovery.
Do not restore a table space that is in roll forward in progress state. If you need to restore the table space, you should first cancel the rollforward operation that is in progress, by issuing ROLLFORWARD with CANCEL option. Otherwise, you might have a table space set in which some table spaces are in roll forward in progress state and some table spaces are in roll forward pending state. A rollforward operation that is in progress operates only on the tables spaces that are in roll forward in progress state.
Do not be connected to the database that is to be rollforward recovered. The rollforward utility automatically establishes a connection to the specified database, and this connection is ended at the completion of the rollforward operation.
About this task
Do not restore table spaces without canceling a rollforward operation that is in progress. Otherwise, you might have a table space set in which some table spaces are in roll forward in progress state, and some table spaces are in roll forward pending state. A rollforward operation that is in progress only operates on the tables spaces that are in roll forward in progress state.
The database can be local or remote.
- You can invoke only one rollforward operation at a time. If there are many table spaces to recover, you can specify all of them in the same operation.
- If you have renamed a table space following the most recent backup operation, ensure that you use the new name when rolling the table space forward. The previous table space name is not recognized.
- You cannot cancel a rollforward operation that is running. You can only cancel a rollforward operation that has completed, but for which the STOP parameter has not been specified, or a rollforward operation that has failed before completing.
- You cannot continue a table space rollforward operation to a point in time, specifying a
time stamp that is less than the previous one. If a point in time is not specified, the previous one
is used. You can issue a rollforward operation that ends at a specified point in time by just
specifying STOP, but this is only allowed if the table spaces involved were all restored from the
same offline backup image. In this case, no log processing is required. If you start another
rollforward operation with a different table space list before the in-progress rollforward operation
is either completed or cancelled, an error message (SQL4908) is returned. Invoke the LIST
TABLESPACES command on all database partitions (or use the MON_GET_TABLESPACE table
function) to determine which table spaces are currently being rolled forward (roll forward in
progress state), and which table spaces are ready to be rolled forward (roll forward pending state).
You have three options:
- Finish the in-progress rollforward operation on all table spaces.
- Finish the in-progress rollforward operation on a subset of table spaces. (This might not be possible if the rollforward operation is to continue to a specific point in time, which requires the participation of all database partitions.)
- Cancel the in-progress rollforward operation.
- In a partitioned database environment, the rollforward utility must be invoked from the catalog partition of the database.
- In a partitioned database environment, it is important to ensure sufficient log files are available on all database partitions to allow the rollforward utility to reach the specified stop time. If there is some log file from a database partition that is damaged or missing, the database can only be recovered to a point in time where the log files from all database partitions are available. If only the log files from the log archive are available, then you cannot use END OF LOGS as the stop time for a rollforward operation. This is because unarchived log files from the active log path are not available, and the rollforward utility processes only available log files. Using END OF LOGS in this situation can result in some database partitions having data that is inconsistent with other database partitions.
- In certain situations, there is an advantage to selecting END OF BACKUP as the stop time for a rollforward operation. When setting up a database by using an online backup image from a database that is still in use, selecting END OF BACKUP minimizes the log files that are required by the rollforward operation. Minimizing the number of log files reduces the work that is needed to have the right log files available to the rollforward utility. If the online backup was taken with the default INCLUDE LOGS option selected, then all the required log files are available in the backup image. By using the LOGTARGET option when restoring the backup, all of the required log files can be restored from the backup image into a location for the rollforward utility to process.
- You cannot roll forward logs from a different release version.
Procedure
- ROLLFORWARD DATABASE command, or
- db2Rollforward application programming interface (API).
- Open the task assistant inIBM® Data Studio for the ROLLFORWARD DATABASE command.
Examples
The following is an example of the ROLLFORWARD DATABASE command issued through the CLP:
db2 rollforward db sample to end of logs and stop