Restore Data - DB2

Topics | How To | Full System Restore | Related Topics


Overview

Restore Considerations for this Agent

DB2 Restore Options

DB2 Advanced Restore Options

Troubleshooting DB2 Restores

Rerun Failed DB2 Restore Jobs

Restoring an Entire Database

Restoring the Database to a New Client (Out-of-Place)

Restore DB2 Databases Created in a User-defined Directory

Restore DB2 Databases with Specific Parameters Containing a Non-default Value

Restore Destinations

Command Line Restore

Third Party Command Line Restores


Overview

The following page describes the agent-specific restore options. Additional restore options are accessible from the Related Topics menu.

The DB2 iDataAgent supports the following types of restores:

Recovery involves two processes: restoring the physical files and then recovering the database. The user can either select backup images to be restored or have the system select the backup image. After the necessary files are restored, the database is recovered (and, in some cases, rolled forward) by applying the appropriate log files.

Additionally, the DB2 iDataAgent supports specific procedures for doing the following:

Depending on your restore options, restores can be performed in-place, out-of-place or cross-platform. (See Restore Destinations below for comprehensive information.) Also, DB2 restore jobs can be run from a third-party command line, and they cannot be suspended unless they are in a pending state.

For the DB2 iDataAgent, restore operations can be performed from the client and backup set levels in the CommCell Browser.

When there is a problem with DB2 database or the client system (operating system, hardware, hard drives, etc.), full system restores may be required. See Restore Data - DB2 iDataAgent - Full System Restore for more information.


Restore Considerations for this Agent

Restore Order of DB2 Backup Images within a Cycle

The system attempts to restore the DB2 backup images within a backup cycle in a specific order, as follows:

For example, assume that Backup Cycle A includes the following backup images (F represents a full backup image, D represents a delta backup image, and I represents an incremental backup image).

Using the rules in the previous bullet list, the backup images in Backup Cycle A would be restored in the following order.

Note that Delta Backup Image 5 (i.e., D5) is the last backup image in Backup Cycle A. Therefore, it is restored first and then last when the backup images in the cycle are restored. Note also that Full Backup Image 1 (i.e., F1) is restored second, and that the remaining backup images are restored in the appropriate order.

The information in this section is important if you try to restore a full backup image along with one or more associated incremental backup images and/or delta backup images but one of these backup images fails to restore. In such a case, you must follow the appropriate steps to implement a successful restore. For more information, see the appropriate how-to topic.


DB2 Restore Options

The following list discusses the DB2-specific restore options that are provided by the agent. The options that are also available to other agents are not discussed here.

The following options are provided from the Restore Options dialog box in the CommCell Browser.

General Option

The General tab allows you to select the data to restore and the destination(s) for the restore. It also provides an option to administer table space containers. You should use this option if your system has lost containers (because of a crash, for example) or if one or more current containers are full.

Restore Arguments Option

The Restore Arguments tab allows you to administer the type of restore, the backup images available for restore, and the DB2 Report File. For each full backup image that you select to restore, be sure to select all associated incremental or delta backup images as well. Whenever this tab is enabled, the Recover Database tab is disabled.

Recover Database Option

The Recover Database tab allows the DB2 iDataAgent to select the backup image to restore and therefore obviates the need for the user to select backup images for restore. The backup image selected is always for the entire database; as such, partial database restores are not supported by this option. Also, out-of-place restores are not supported by this option. Whenever this option is enabled, the Restore Arguments tab is disabled.

If the database to be recovered is dropped or deleted, you cannot use this option. In such a case, click Advanced and use the Roll-Forward option.

DB2 Advanced Restore Options

The following options are provided from the Advanced Restore Options dialog box in the CommCell Browser.

These options will be disabled if you use the Recover Database tab.

Log Files Option

The Log Files tab allows you to administer log file restores. Whenever log files are restored without rolling forward the database, the files are restored to the DB2 Retrieve Path that was specified during the installation of the DB2 iDataAgent.

You do not need (and are not able) to use the Roll-Forward tab if you use the Recover Database tab to have the DB2 iDataAgent select the backup image for restore. You can use the Roll-Forward tab if you use the Restore Arguments tab to select the backup images for restore.

Restoring All Log Files

Use the following steps to restore all of the log files.

  1. From the CommCell Browser, navigate to Client Computers | <Client> | DB2 iDataAgent | <Instance>.
  2. Right-click the <BackupSet>, point to All Tasks, and then click Restore.
  3. Click Advanced, and then click the Log Files tab.
  4. Select the Restore Log Files check box.
  5. Click All Log Files.
  6. Click OK.

Restoring Log Files by Point-in-Time

Use the following steps to restore log files to a point-in-time.

  1. From the CommCell Browser, navigate to Client Computers | <Client> | DB2 iDataAgent | <Instance>.
  2. Right-click the <BackupSet>, point to All Tasks, and then click Restore.
  3. Click Advanced, and then click the Log Files tab.
  4. Select the Restore Log Files check box.
  5. Click Point in Time.
  6. Select the Start and End check boxes to specify the point in time (date and time) for restore of log files. 
  7. Click OK.

Restoring Log Files by Log Serial Number

Use the following steps to restore log files to a point-in-time.

  1. From the CommCell Browser, navigate to Client Computers | <Client> | DB2 iDataAgent | <Instance>.
  2. Right-click the <BackupSet>, point to All Tasks, and then click Restore.
  3. Click Advanced, and then click the Log Files tab.
  4. Select the Restore Log Files check box.
  5. Click By Log Serial Number.
  6. Select the Start and End log serial numbers for restore. 
  7. Click OK.

Redirect Option

The Redirect tab allows you to rename one or more table spaces or table space containers upon restore. Renaming these items as they are restored allows them to be restored without overwriting existing table spaces or table space containers.

Redirecting All Table Spaces

Use the following steps to redirect all the table spaces.

  1. From the CommCell Browser, navigate to Client Computers | <Client> | DB2 iDataAgent | <Instance>.
  2. Right-click the <BackupSet>, point to All Tasks and then click Restore.
  3. Click Advanced, and then click the Redirect tab.
  4. Select the Redirect All Table Spaces To check box.
  5. Click Browse to select the new location to redirect the table spaces during restore operation.
  6. Click OK.

Redirecting Specific Table Spaces

Use the following steps to redirect specific table spaces.

  1. From the CommCell Browser, navigate to Client Computers | <Client> | DB2 iDataAgent | <Instance>.
  2. Right-click the <BackupSet>, point to All Tasks and then click Restore.
  3. Click Advanced, and then click the Redirect tab.
  4. Select the Redirect Table Space Containers check box.
  5. From the Table Space box  select the required table space to be redirected, the associated container name is displayed in the Container Name box.
  6. Click Add to create a new container for the selected table space to redirect.
  7. Click Browse to select the new location to redirect the table space during restore operation.
  8. Click OK.

Storage Paths Option

An automatic storage database is one in which container and space management characteristics are completely determined by the DB2 database manager. We cannot use redirect restore process for automatic storage databases. For automatic storage databases the Storage Paths tab will appear instead of Redirect tab in the Advanced Restore Options dialog box.

Redirecting Automatic Storage Databases

Use the following steps to restore table space of an automatic storage database to another path.

  1. From the CommCell Browser, navigate to Client Computers | <Client> | DB2 iDataAgent | <Instance>.
  2. Right-click the <BackupSet>, point to All Tasks and then click Restore.
  3. Click the Recover Database tab, and then clear the Recover DB check box.
  4. Click Advanced, and then click the Storage Paths tab.
  5. Select the Specify Storage paths check box.
  6. Click Browse to select the new path or click Add Paths to type the new path.
  7. Click OK.

Roll-Forward Option

The Roll-Forward tab allows you to recover the DB2 database by reapplying the log files containing transactions that are not part of any database backup image. The roll-forward capability is invoked after a database or table space image is restored. Before the database can be "rolled forward," you must perform log archiving by doing one or both of the following: having the logretain database configuration parameter set to "RECOVERY"; and/or enabling the userexit database configuration parameter.

Whenever log files are restored with the roll-forward option activated, DB2 searches for the following target restore paths per the following order: DB2's own directory path for log file restores; the DB2 Retrieve Path that was specified during the installation of the DB2 iDataAgent; the DB2 Archive Path that was specified during the installation of the DB2 iDataAgent; and the path identified (if any) in the Overflow Directory field within the Roll-Forward tab.

If DB2 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 iDataAgent.

Roll Forward to the End of Logs

Use the following steps to reapply all of the logs to the database after a restore.

  1. From the CommCell Browser, navigate to Client Computers | <Client> | DB2 iDataAgent | <Instance>.
  2. Right-click the <BackupSet>, point to All Tasks, and then click Restore.
  3. Click Advanced, and then click the Roll-Forward tab.
  4. Select the Roll-forward check box.
  5. Click To the End of the logs, to reapply all of the logs.
  6. Click Browse to select the Overflow Directory. If the required log file is not present in the location specified by the logpath database configuration parameter, DB2 searches the overflow directory.
  7. Select the Alternate Log Path check box, and then click Browse to select another location within the DB2 directory for the log files.
  8. Click OK.

Roll Forward to a Point-in-Time

Use the following steps to reapply logs till a point-in-time to the database after a restore.

  1. From the CommCell Browser, navigate to Client Computers | <Client> | DB2 iDataAgent | <Instance>.
  2. Right-click the <BackupSet>, point to All Tasks, and then click Restore.
  3. Click Advanced, and then click the Roll-Forward tab.
  4. Select the Roll-forward check box.
  5. Click To a Point in Time, and then select date and time to reapply the logs upto a specific point in time.
  6. Click Browse to select the Overflow Directory. If the required log file is not present in the location specified by the logpath database configuration parameter, DB2 searches the overflow directory.
  7. Select the Alternate Log Path check box, and then click Browse to select another location within the DB2 directory for the log files.
  8. Click OK.

Leave in Roll Forward Pending State

Use the following steps to keep the database in a pending state till the logs are reapplied.

  1. From the CommCell Browser, navigate to Client Computers | <Client> | DB2 iDataAgent | <Instance>.
  2. Right-click the <BackupSet>, point to All Tasks, and then click Restore.
  3. Click Advanced, and then click the Roll-Forward tab.
  4. Select the Leave in Roll-forward Pending State check box to leave the database in a roll-forward pending state.
  5. Click OK.

Troubleshooting DB2 Restores

You can troubleshoot restores by checking the CLDb2Agent restore log located <software installation path>\Log Files. Also, you can check details on the restore by issuing the db2ckrst DB2 command and then reviewing the generated output. The output for this command lists all of the backup images involved in the restore. The command syntax is as follows:

db2ckrst [-d <database name>] [-t <timestamp string>]

where:

<database name> is the name of the database
<timestamp string> is a numerical value representing the backup image involved
in the restore.

Timestamps are displayed in the Restore Options (Restore Arguments) dialog box in the CommCell Browser.

For example:

db2ckrst -d db_one -t 20030224125749

might generate the following output:

Suggested restore order of images using timestamp 20030224125749
for database db_one

============================================================
restore db db_one incremental taken at 20030224125749
restore db db_one incremental taken at 20030224124314
restore db db_one incremental taken at 20030224125211
restore db db_one incremental taken at 20030224125749
=============================================================

In this example, note that the timestamp for the database image included in the command appears twice in the output — in the first line and in the last line. This indicates that this (delta or incremental) backup image was the last backup image in the backup cycle and therefore was restored first and then last among all of the backup images in the cycle.


Rerun Failed DB2 Restore Jobs

If a restore job fails, and if the job contains just one backup image, you can simply rerun the restore job as you had done previously. However, if the failed restored job contains multiple backup images, you must rerun the restore job by following the appropriate procedure. One procedure is based on a full backup image restore failure, while the other procedure is based on either a delta backup image restore failure or an incremental backup image restore failure.

You can view backup image restore failures by checking the system logs. For information on system logs, see Log Files. Also, you can view details on all the backup images included in a restore by checking the output of the db2ckrst command.

See Restore Order of DB2 Backup Images within a Cycle for a discussion of restoring multiple DB2 backup images within a backup cycle.


Restoring an Entire Database

You can restore an entire DB2 database after you bring down the affected database offline. However, the database will be deactivated and all the db2 non administrative users will be disconnected automatically during a restore operation. The system will automatically activate the database after the restore operation.

Follow the steps given below to restore an entire db2 database:

  1. From the CommCell Browser, navigate to Client Computers | <Client> | DB2 iDataAgent | <Instance>.
  2. Right-click the <BackupSet>, point to All Tasks and then click Restore.
  3. Select Restore Data check box and click Entire Database option.
  4. Click OK to start the restore.

Restoring the Database to a New Client (Out-of-Place)

When restoring databases to a new client, ensure the following:

  1. From the CommCell Browser, navigate to Client Computers | <Client> | DB2 | <Instance>.
  2. Right-click the <BackupSet>, point to All Tasks, and then click Restore.
  3. Click the Recover Database tab.
  4. Clear the Recover DB check box.
  5. Click the General tab.
  6. In the Destination client box, select the destination client name.
  7. In the Destination Instance, select the instance name.
  8. In the Target Database Name, select the database name.
  9. In the Target Database path, type the location of the target database. Alternatively, click browse to select the path.
  1. Click Advanced.
  2. Click the Storage Paths tab.
  3. Select the Specify Storage paths check box.
  4. Click Browse to locate the new path or click Add Paths to type the new path.
  5. Click OK.

If the original host is damaged, you can restore the DB2 database to a different instance on the same host or to a different host. Whenever you perform a cross-machine restore, ensure that the destination computer has sufficient disk space to accommodate the restored database.

Restore DB2 Databases Created in a User-defined Directory

If you defined your own directory for the database instead of using the DB2 default location when you created the database, you cannot restore this database to either a new database or another instance in the conventional manner.


Restore DB2 Databases with Specific Parameters Containing a Non-default Value

If the DBHEAP, UTIL_HEAP, and/or APP_CTL_HEAP_SZ configuration parameters for the (source) database that you want to restore contain a value other than the default value, you cannot restore this database to either a new database or another instance in the conventional manner.


Restore Destinations

By default, the DB2 iDataAgent restores data to the client computer from which it originated; this is referred to as an in-place restore. You can also restore the data to another Client computer in the CommCell. Keep in mind the following considerations when performing such restores:

The following section enumerates the types of restore destinations that are supported by the DB2 iDataAgent. See Restore/Recover/Retrieve Destinations - Support for a list of Agents supporting each restore destination type.

In-Place Restore

Out-of-Place Restore

Keep in mind that out-of-place restore operations are also subject to the conditions described in Cross-Platform Restores.

Out-of-place restores are not supported by the Recover Database option.

Cross-Platform Restores


Command Line Restore

You can perform restores of one of more databases from the command line interface.

Command line restores enable you to perform restore operations on multiple clients at the same time. It also allows you to reuse the command line scripts for additional restores.

When performing command line restores, note that backups taken from the CommCell Console can be restored using Command Line and vice versa. However, backups taken from a previous version of the CommCell Console can be restored only from the Command Line.

In order to run the restores from command line, you need an input xml file which contains the parameters for configuring the restore options. This input xml file can be obtained using one of the following ways:

Log on to the Commserve

To run command line operations you must first login to the CommServe as follows:

Perform the Restore

  1. Execute the saved xml script using qoperation execute command.

       qoperation execute -af recover_template.xml -clientName <DB2CleintName> -instanceName <DB2InstanceName> -backupsetName <DB2BackupSetName>

       Example

       qoperation execute -af qoperation_db2_recover.xml -clientName dbserveaix2 -instanceName db2inst5 -backupsetName TESTDB

  1. Verify the status of the job using the following command:
    qlist job –j JOBID
  2. Once the job completes, logout from the CommServe using the qlogout command.

    qlogout [-cs commserver] [-all] [-tf tokenfile] [-tk token] [-h]

Third Party Command Line Restores

Use the following steps to restore a DB2 database. You must deactivate the database before performing a DB2 database restore.

  1. At the Command Prompt, type the appropriate restore command for the specific platform.

    where <software install path> is the install path for the agent software (e.g., level1/install); and <backup image date> is the date of the backup image in the following format: "YYYYMMDDHHMMSS" (e.g., 20070612120426).

  2. Roll forward the DB2 database:

    db2 rollforward db <database name> to end of logs and complete

Restore from a Full Backup Image

1. At the Command Prompt, type the restore command. db2 restore db <database name> load '<software install path>/Base/libDb2Sbt.so' taken at <backup image date> without prompting

Restore from an Incremental Backup Image

1. At the Command Prompt, type the restore command. db2 restore db <database name> incremental automatic load '<software install path>/Base/libDb2Sbt.so' taken at <backup image date> without prompting

Restore from a Delta Image

1. At the Command Prompt, type the restore command. db2 restore db <database name> incremental automatic load '<software install path>/Base/libDb2Sbt.so' taken at <backup image date> without prompting

Restore from Multi Stream Backups

When you perform third party command line restores from multiple stream backups, the restore operation will generate separate job ID for each stream.
You can perform a third party command line restore from a multistream backup image using the following steps. Note that the number of streams specified for the restore should be same as the number of streams used by the backup image.

1.. At the Command Prompt, type the appropriate restore command for the specific platform. On Unix client:

db2 restore db <db_name> load '<software install path>/Base(or Base64)/libDb2Sbt.so' open <n> sessions taken at <backup_image>

On Windows client:

db2 "restore db <db_name> load '<software install path>\Base\Db2Sbt.dll' open <n> sessions taken at <backup_image>"

2. Roll forward the DB2 database db2 rollforward db <database name> to end of logs and complete

Cross Database Restore on Same Instance

Use the following steps to perform  a cross-database restore involving the same DB2 instance, assume, for example, that the name of the source database is pubs and that the name of the target database is emp.

1. At the Command Prompt, type the restore command. db2 restore db pubs load <source software install path>/Base/libDb2Sbt.so taken at 20080627113811 on <destination software install path> into emp
2. Set the CvSrcDbName option for the LOGARCHOPT1 parameter to the source database name. db2 update db cfg for emp using LOGARCHOPT1 "'CvSrcDbName=pubs,CvClientName=<client name>,CvInstanceName=<CommServe instance name>"'
3. Roll forward the DB2 database db2 rollforward db emp to end of logs and stop

Cross Database Restore to Different Instance on Same Client

Use the following steps to perform a cross-database restore involving different DB2 instances on the same client, assume, for example, that the name of the (source and destination) client is supernova, the name of the source DB2 instance is db2inst3, the name of the source database is pubs, the name of the destination DB2 instance is db2inst4, and the name of the destination database is emp01. Also, assume that the CommServe instance name (in a multi-instance environment) is Instance001.

1. Set the CvSrcDB2InstanceName option to the source database name in the VENDOROPT parameter (in this example, db2inst3). db2 update db cfg for emp01 using VENDOROPT "'CvSrcDB2InstanceName=db2inst3,CvClientName=supernova,

CvInstanceName=Instance001"'

2.. At the Command Prompt, type the restore command. db2 restore db pubs load <source software install path>/Base/libDb2Sbt.so taken at 20080627113811 on <destination software install path> into emp01
3. Set the CvSrcDbName option to the source database name and the CvSrcDB2InstanceName option to the source DB2 instance name in the LOGARCHOPT1 parameter. db2 update db cfg for emp01 using LOGARCHOPT1 "'CvSrcDbName=pubs,CvSrcDB2InstanceName=db2inst3,

CvClientName=supernova, CvInstanceName=Instance001"'

4. Roll forward the DB2 database db2 rollforward db emp to end of logs and stop

Cross Database Restore to Different Client

For a cross-database restore involving different DB2 instances on different clients, assume, for example, that the name of the source client is supernova, the name of the source DB2 instance is db2inst3, the name of the source database is pubs, the name of the destination client is neutronstar, the name of the destination instance is db2inst4, and the name of the destination database is emp. Also, assume that the CommServe instance name (in a multi-instance environment) is Instance001.

1. Set the CvSrcClientName option to the source client name and the CvSrcDB2InstanceName option to the source database name in the VENDOROPT parameter (in this example, db2inst3). db2 update db cfg for emp01 using VENDOROPT "'CvSrcClientName=supernova,CvSrcDB2InstanceName=db2inst3,

CvClientName=neutronstar,CvInstanceName=Instance001"'

2. At the Command Prompt, type the restore command. db2 restore db pubs load <source software install path>/Base/libDb2Sbt.so taken at 20080627113831 on <destination software install path> into emp
3. Set the CvSrcDbName option to the source database name, the CvSrcClientName option to the source client name, and the CvSrcDB2InstanceName option to the source instance name in the LOGARCHOPT1 parameter. db2 update db cfg for emp using LOGARCHOPT1

"'CvSrcDbName=pubs,CvSrcClientName=supernova,

CvSrcDB2InstanceName=db2inst3,CvClientName=neutronstar,

CvInstanceName=Instance001"'

4. Roll forward the DB2 database db2 rollforward db emp to end of logs and stop

Back to Top