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 Tivoli® Storage Manager
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 Tivoli Storage Manager) 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

To restore a Tivoli Storage FlashCopy® Manager snapshot backup in a DB2 pureScale® environment, use the same commands as defined in table summary of restore commands for DB2. Issue the command from any of the pureScale member nodes.

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" 
For DB2 in an SAP environment only, 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 Tivoli Storage FlashCopy Manager 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 Tivoli Storage FlashCopy Manager snapshot backup of a DB2 HADR standby server. Before, you restore ensure that you stop the DB2 HADR function and deactivate the DB2 database. Tivoli Storage FlashCopy Manager stops the DB2 manager before the restore operation. If the DB2 HADR is still running or the database is still active, Tivoli Storage FlashCopy Manager cannot stop the DB2 manager and the restore is not successful.

A restore operation of an offloaded tape backup from Tivoli Storage Manager can be performed by running Tivoli Storage Manager backup-archive client commands on the DB2 HADR standby server. A proxy node setup can be used.

Tivoli Storage FlashCopy Manager 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 Tivoli Storage Manager backup, other than the time when either backup was created. In configurations where the offloaded Tivoli Storage Manager backup is scheduled at a different time from the snapshot backup, this correlation can be difficult to achieve. If you want to maintain that relationship explicitly in the offload section of the Tivoli Storage FlashCopy Manager profile configuration file, set the MODE parameter to ARCHIVE. This way, Tivoli Storage FlashCopy Manager can correlate both backup methods by using the snapshot backup ID as the archive description for the offloaded backup.