Question & Answer
Question
"A connection to or activation of database <dbname> cannot be made because of ROLL-FORWARD PENDING"
Cause
After restoring an online backup image, rollforward is mandatory. Rollforward applies any changes to the database whilst an online backup was in progress. Until the rollforward is completed, the database is in an inconsistent state.
By default, an online backup image includes the transaction log files which is needed to make the database consistent. The log files can be retrieved from the backup image and used to rollforward.
If restoring from an offline backup image, the "rollforward pending" state can be reset using the WITHOUT ROLLING FORWARD option in the RESTORE command.
Answer
- Login on the target system as the instance owner.
- Execute this command to retrieve the log files into the path specified in the "logtarget" parameter:
$ db2 restore db sample from /data/backup logtarget /tmp/logs
Note: If a database restore was already performed, the transaction log files can be retrieved by using the "logs" option:
$ db2 restore db sample logs from /data/backup logtarget /tmp/logs - Execute the following rollforward command to use the log files retrieved into "logtarget" path:
$ db2 "rollforward db sample to end of backup and stop overflow log path ('/tmp/logs')"
Restoring an offline backup
In the following scenario, assume the offline backup image of the SAMPLE database is placed in the directory /data/backup.
- Login on the target system as the instance owner.
- Execute this command to restore the backup image with the WITHOUT ROLLING FORWARD option.
$ db2 restore db sample from /data/backup without rolling forward
Additional tips:
The db2ckbkp command can be used to determine whether the backup was taken in an online or offline mode. It can also be used to check if transaction log files are included in an online backup image.
(Unix/Linux)
$ db2ckbkp -h <path_to_backup_image> | grep -e Mode -e Includes
(Windows)
C:\>db2ckbkp -h <path_to_backup_image> | findstr "Mode Includes"
Sample output:
$ db2ckbkp -h /data/backup/SAMPLE.0.db2inst1.DBPART000.20171107164502.001 | grep -e Mode -e Includes
Backup Mode -- 1 (Online)
Includes Logs -- 1 (Yes)
With version 9.7 FP2 and later, the registry variable DB2_RESTORE_GRANT_ADMIN_AUTHORITY was introduced. This automatically grants the instance owner SECADM, DBADM, DATAACCESS, and ACCESSCTRL privileges on the databases restored. From version 9.7 FP5, the setting is dynamic and does not require an instance restart.
Was this topic helpful?
Document Information
Modified date:
24 October 2019
UID
ibm11074606