Loading...

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

You can perform a restore to a different instance on the source host.

Procedure

The names of the items in the examples are as follows:

  • Name of the client - Client1
  • Name of the source DB2 instance - db2inst3
  • Name of the source database - source
  • Name of the destination DB2 instance - db2inst4
  • Name of the destination database - target
  • Default instance in a multi-instance environment - Instance001

    If you created more than one 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)
  1. Set the CvSrcDB2InstanceName option to the source instance name in the VENDOROPT parameter.

    db2 update db cfg for target using VENDOROPT "'CvSrcDB2InstanceName=source_instance_name,CvSrcDB2DbName=source_database_name,CvClientName=client_name, CvInstanceName=Instance001'"

  2. 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

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

  4. 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'

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

    db2 restore db source CONTINUE

  6. 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 and the CvSrcDB2InstanceName parameter to the source DB2 instance name in the parameters.

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

    db2 update db cfg for target using VENDOROPT "'CvSrcDbName=source_database_name,CvSrcDb2InstanceName=source_instance_name,CvClientName=source_client_name,CvInstanceName=Instance001'"

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

    db2 rollforward db target to end of logs and stop

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

Last modified: 1/17/2020 11:01:01 PM