# DB2 Command Line Example: Restoring to a Different Database on the Source Host

Perform a restore to a different database on the source host.

## Procedure

In a Commvault multi-instance environment, the default instance is Instance001. If you created more than one Commvault instance and you want to use a non-default instance, you must set the instance parameter to the non-default instance name, for example, Instance002.

Note

The backup image timestamp is 14 characters. It has the following format:

yyyymmddhhmmss

- yyyy - the year

- mm - the 2 digit month representation (01-12)

- dd - the day of the month

- hh - the hour in 24-hour clock format (00-23)

- mm - the minute (0-59)

- ss - the second (0-59)

- Set the CvSrcDB2DbName option to the source database name in the VENDOROPT parameter.

       db2 update db cfg for $[target] using VENDOROPT "'CvSrcDB2DbName=$[source_database_name],CvClientName=$[client_name], CvInstanceName=$[Instance001]'"

- At the command prompt, run the following restore command:

       db2 restore db $[source] load $[/opt/commvault/Base/libDb2Sbt.so] taken at $[backup_image_timestamp] on $[database-storage-path-location] into $[target] REDIRECT

- Set the tablespace containers for non-automatic tablespaces.

  Note

  The file path is the location where the tablespace data is restored. It must be an absolute file path or relative to the database directory. The maximum file path length is 254 characters.

       db2 set tablespace containers for $[tablespace_id] using $[file_path] $[number_of_pages]

  Example:

      db2 set tablespace containers for $[3] using file '$[E:\DB2_0 3\NODE0000\DBNOAU2\userspace2_01.dbf]' $[2000]

- Set the storage group paths for the automatic storage table spaces:

       db2 set stogroup paths for $[storage_group_1] on $['path_1', 'path_2']
      db2 set stogroup paths for $[storage_group_2] on $['path_3', 'path_4']

- Run the following command to continue the restore operation:

      db2 restore db $[source] CONTINUE

- Update the DB2 database configuration parameters LOGARCHOPT1 and VENDOROPT. This is needed because the source database overwrites these parameters after a restore. Set the CvSrcDbName parameter to the source database name in the parameters.

       db2 update db cfg for target using LOGARCHOPT1 "'CvSrcDbName=$[source_database_name],CvClientName=$[source_client_name], CvInstanceName=$[Instance001]'"

       db2 update db cfg for target using VENDOROPT "'CvSrcDbName=$[source_database_name],CvClientName=$[source_client_name],CvInstanceName=$[Instance001]'"

- Run the following command to roll forward the DB2 database:

      db2 rollforward db $[target] to end of logs and stop

- The destination is configured for a cross machine restore. You must update the destination configuration to remove the following cross-machine restore parameters: CvSrcDbName and CvClientName.

×

Loading...