DB2 Command Line Example: Recovering the Database

You can recover the database by reapplying the log files containing transactions that are not part of any database backup image. The roll-forward capability is applied after a database or table space image is restored.

Before reapplying the logs (roll-forward) on the restored database, you must enable the logarchmeth1 database configuration parameter to perform the log archiving.

Whenever the log files are restored with the roll-forward capability, DB2 searches for the following target restore paths:

  • DB2's own directory path for log file restores

  • The retrieve path that was specified during the installation of the DB2 agent

  • The archive path that was specified during the installation of the DB2 agent

  • The path identified (if any) in the Overflow Directory field within the roll-forward. For more information about the overflow directory, go to overflowflowpath - Overflow log path configuration parameter on the IBM DB2 documentation website.

If the system is unable to find any of these paths, the appropriate error is reported in a file within the DB2 Audit Error Path that was specified during installation of the DB2 agent. After recovering the database, you will not be able to reapply the logs.

Procedure

Recover to the End of the Logs

  • At the DB2 command prompt, type the following command, substituting the database_name with your database name:

    db2 recover database <database_name>

Recover to a Point in Time

  • At the DB2 command prompt, type the following command and change the timestamp:

    db2 recover db <database_name> to 2001-12-31-04.00.00

Loading...