# DB2 Command Line Example: Restoring to a Different Instance on a Different Host

You can perform a restore to a different instance on a new host.

## Procedure

In this example, the name of the source client is client1, the name of the source DB2 instance is db2inst3, the name of the source database is source, the name of the destination client is client2, the name of the destination instance is db2inst4, and the name of the destination database is target. The Commvault instance name (in a multi-instance environment) is Instance001.

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

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

- mm - the minute (0-59)

- ss - the second (0-59)

1. Set the CvSrcClientName option to the source client name and the CvSrcDB2InstanceName option to the source database name in the VENDOROPT parameter on the destination database.

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

   Example

       db2 update db cfg for $[target] using VENDOROPT "'CvSrcDbName=$[source],CvSrcDB2InstanceName=$[db2inst3],CvSrcClientName=$[client1],
        CvClientName=$[client2],CvInstanceName=$[Instance001]'"

2. At the command prompt, run the restore command.

   For an automatic storage database:

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

   Note

   If the Commvault software path is different on the source client and the target client, specify the Commvault software path of the target client.

   Example:

       db2 restore db $[source] load $[/opt/commvault/Base/libDb2Sbt.so] taken at $[201610226100000] on $[/temp/test] into $[target] REDIRECT

   For a non-automatic storage database:

        db2 restore db $[source] load $[/opt/commvault/Base/libDb2Sbt.so] taken at $[backup_image_timestamp] into $[target] WITHOUT PROMPTING

   Example:

       db2 restore db $[source] load $[/opt/commvault/Base/libDb2Sbt.so] taken at $[201610226100000] into $[target] WITHOUT PROMPTING

3. 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']

4. Run the following command to continue the restore operation:

       db2 restore db $[source] continue

5. Update the DB2 database configuration parameters LOGARCHOPT1, VENDOROPT because the source database overwrites these parameters after a restore. Set the CvSrcDbName parameter to the source database name, the CvSrcClientName parameter to the source client name, and the CvSrcDB2InstanceName parameter to the source instance name in the LOGARCHOPT1 parameter.

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

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

   Example:

       db2 update db cfg for $[target] using LOGARCHOPT1 "'CvSrcDbName=$[source],CvSrcDB2InstanceName=$[db2inst3],CvSrcClientName=$[client1],CvClientName=$[client2], CvInstanceName=$[Instance001]'"

       db2 update db cfg for $[target] using VENDOROPT "'CvSrcDbName=$[source],CvSrcClientName=$[client1],CvSrcDB2InstanceName=$[db2inst3],CvClientName=$[client2],CvInstanceName=$[Instance001]'"

   Commvault software installation path is different on the source machine and the target machine:

   For Unix

       db2 update db cfg for $[target] using logarchmeth1 "'Vendor:$[C:/commvault/commvault/Base/libDb2Sbt.so]'"

   For Windows

       db2 update db cfg for $[target] using logarchmeth1 "'Vendor:$[C:\commvault\commvault\Base\Db2Sbt.so]'"

6. Run the following command to roll forward the DB2 database:

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

7. The destination is configured for a cross machine restore. You must update the destination configuration to remove the cross-machine restore parameters (CvSrcDbName, CvSrcInstanceName, and CvClientName).

×

Loading...