Restoring DB2 databases

To restore a DB2® database, open a command-line window.

The following table summarizes the command entries according to the database configuration and type of restore:
Table 1. Summary of Restore Commands for DB2
Database configuration Snapshot restore Restore from IBM Spectrum Protect™
DB2 db2 restore ... use snapshot ... db2 restore ... or db2 recover ...
DB2 in an SAP environment db2 restore ... use snapshot ... db2 restore ... or db2 recover ... or backom

Depending on the options that are specified in the db2 backup ... use snapshot ... command when the snapshot is created, both backup types (snapshot and IBM Spectrum Protect) can be restored. The background copy must be completed before you restore a snapshot backup even if the snapshot backup request completed successfully. When you restore from snapshots, all objects on target volumes that are created in the backup snapshot process are restored.

The default behavior when you restore data from a snapshot image is a full database offline restore of all paths that make up the database. This restore includes all containers, the local volume directory, and the database path but does not include the database log files. To restore a snapshot, issue the following command:
db2 restore db DBNAME use snapshot taken at TIMESTAMP
Where TIMESTAMP is a string that represents the time stamp of the backup image and is optional if there is only one backup image in the source specified. The log files are excluded by default from the restore unless you specify the logtarget include option. To restore log files, table spaces, and directories, issue the following command:
db2 restore db DBNAME use snapshot taken at TIMESTAMP logtarget include
Note: Using some storage systems, the snapshot restore requires a certain amount of available space on the target storage pool, so that it can restore the necessary volume. If there is not enough storage space available, you can increase the capacity on the requested storage pool, or free up some items that are using existing capacity. Check the message for the exact amount of storage space that is required.

In a more complex environment, use the following commands to restore a DB2 multi-partition snapshot:

(catalog node first)
db2_all "<<+0< db2 restore db H80 use snapshot without prompting" 
(remaining nodes)
db2_all "<<-0< db2 restore db H80 use snapshot without prompting" 
If the PARTITION_GROUP parameter was specified when the snapshot was created, you cannot use the db2 restore command to restore the snapshot. For this scenario, use the IBM Spectrum Protect Snapshot fcmcli command with the following syntax:
fcmcli -f restore -d <dbname> -B <backupID> -P <partition group name>
If more than one partition group is used during the backup, the restore operation must be completed for all partition groups.

Restoring DB2 HADR and DB2 standby server environments

Use the fcmcli -f restore_db2standby command to restore a IBM Spectrum Protect Snapshot snapshot backup of a DB2 HADR standby server. Before you restore, ensure that you stop the DB2 HADR function and deactivate the DB2 database. IBM Spectrum Protect Snapshot stops the DB2 manager before the restore operation. If the DB2 HADR is still running or the database is still active, IBM Spectrum Protect Snapshot cannot stop the DB2 manager and the restore is not successful.

A restore operation of an offloaded tape backup from IBM Spectrum Protect can be done by running IBM Spectrum Protect backup-archive client commands on the DB2 HADR standby server. A proxy node setup can be used.

IBM Spectrum Protect Snapshot maintains a backup ID that can uniquely identify any snapshot backup. Backup-archive client backups are not associated with backup IDs. Therefore, there is no correlation between a snapshot backup and its corresponding IBM Spectrum Protect backup, other than the time when either backup was created. In configurations where the offloaded IBM Spectrum Protect backup is scheduled at a different time from the snapshot backup, a time correlation can be difficult to achieve.

Tip: If you want to maintain that relationship explicitly in the offload section of the IBM Spectrum Protect Snapshot profile, set the MODE parameter to ARCHIVE. This way, IBM Spectrum Protect Snapshot can correlate both backup methods by using the snapshot backup ID as the archive description for the offloaded backup.