Loading...

DB2 Command Line Example: Restoring from a Secondary Copy

You can restore from a secondary copy to the same database, a new database or a new host.

Procedure

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)

In-Place Restore

  1. Update the database configuration parameter VENDOROPT that needs to be restored with the option to use the required copy precedence, client name and Commvault instance:

    db2 update db cfg for <database_name> using VENDOROPT "'CvClientName=clientname,CvDb2RestoreCopyPrec=<copy_prec_number>,CvInstanceName=Instance00x'"

    Example:

    db2 update db cfg for testdb1 using VENDOROPT "'CvClientName=windb2test1,CvDb2RestoreCopyPrec=2,CvInstanceName=Instance001'"

  2. At the DB2 command prompt, type the following command to restore from a secondary copy:

    db2 restore db <database_name> load "'/opt/commvault/Base/libDb2Sbt.so’" taken at <backup_image_timestamp>

    Example:

    db2 restore db testdb1 load "'/opt/commvault/Base/libDb2Sbt.so’" taken at 20120417152658

    Where:

    testdb1 is name of the database.

    CvClientName is the name of the client machine as it appears in the CommCell Console

    CvDb2RestoreCopyPrec is the copy precedence number as it appears in the Storage policy properties

    CvInstanceName is the Commvault Instance Name

    20120417152658 = timestamp of the backup image that is being restored

Cross-Machine or Cross-Database Restore

Use the following steps to perform a cross machine or cross database restore from secondary copy using the DB2 command line:

  1. Update the database required for cross machine\cross database restore from secondary copy with the option to use the required copy precedence, client name and Commvault instance.

    db2 update db cfg for <database_name> using VENDOROPT "'CvClientName=clientname,CvDb2RestoreCopyPrec=<copy_prec_number>,CvInstanceName=Instance00x'"

    Example:

    db2 update db cfg for testdb2 using VENDOROPT "'CvClientName=windb2test1,CvDb2RestoreCopyPrec=2,CvInstanceName=Instance001'"

  2. At the DB2 command prompt, type the following command to cross machine\cross database restore from secondary copy with copy precedence as 2:

    db2 restore db sample load /opt/commvault/Base/libDb2Sbt.so taken at  <backup_image_timestamp> into target redirect

    Example for cross machine\cross database restore from secondary copy with copy precedence as 2:

    db2 restore db sample load "'/opt/commvault/Base/libDb2Sbt.so’" taken at 20120417152658 into testdb2 redirect

    Where:

    source = source db name

    testdb2 = target db name

    CvClientName is the name of the client computer as it appears in CommCell Console.

    CvDb2RestoreCopyPrec is the copy precedence number as it appears in the storage policy properties

    CvInstanceName is the Commvault Instance name

    20120417152658= timestamp of the backup image that is being restored.

  3. Set the tablespace containers.

    Note: The file path is the place where the tablespace data is restored. It must be an absolute file path or relative to the database directory. The maximum file path 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. Run the following command to continue the restore operation:

    db2 restore db source CONTINUE

  5. Update the target testdb2 database by using the LOGARCHOPT1 configuration parameter.

    db2 update db cfg for testdb2 using LOGARCHOPT1 "'CvSrcDbName=source,CvClientName=windb2test1,CvInstanceName=Instance001,CvDb2RestoreCopyPrec=2'"

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

    db2 rollforward db target to end of logs and complete.

    Example:

    db2 rollforward db testdb2 to end of logs and complete

 

Last modified: 7/10/2018 2:58:56 PM