You can can use the db2util.sh on UNIX to query, and then restore the backup images to a disk. You must be a valid DB2 user to run this DB2 utility. The Commvault user must have the browse and view capability to query DB2 backup jobs.
Procedure
-
On the command line, use qlogin from the software_installation_directory/Base directory, and then go to the software_installation_directory/iDataAgent directory, where db2util.sh resides.
su – db2instance_name cd software_installation_directory/Base ./qlogin –cs commserve_name -u commcell_user_name cd software_installation_directory/iDataAgent -
On the command line, type the following command to see the script options.
./db2util.sh -hFor information about the query options, the restore options, and the input file parameters, see Options and Input File Parameters.
-
On the command line, run the script to query the data or log backups.
./db2util.sh -q LOG | DATA |ALL -d db2_database_name -s db2_MultiNode_instance_name -c db2_MultiNode_pseudo-client_name [-i commvault_instance_name] [-f start_time] [-t end_time] -
On the command line, run the script to restore the backups to disk.
./db2util.sh -r JOB|LOG -d database_name <[-j jobId] | [-f start_log_sequence_number -t end_log_sequence_number]> [-s source_db2_instance_name] [-p restore_directory] [-c client_name] [-k target pseudo-client name] [-n DPF] [-i Commvault_instance_name] -
After the job completes, use the qlogout command.
qlogout [-cs commserve] [-all] [-tf tokenfile] [-tk token] [-h]
Examples
Querying the data and log backups
Use the following command to query data.
/db2util.sh -q data -c db2_MultiNode_pseudo-client_name -s db2_MultiNode_instance_name -d database_name [-i commvault_instance_name]
Use the following command to query logs.
/db2util.sh -q log -c db2_MultiNode_pseudo-client_name -s db2_MultiNode_instance_name -d database_name [-i commvault_instance_name]
Use the following command to query both data and logs.
/db2util.sh -q all -c db2_MultiNode_pseudo-client_name -s db2_MultiNode_instance_name -d database_name [-i commvault_instance_name]
Use the following command to query both data and logs in a specific time range:
/db2util.sh -q ALL -c db2_MultiNode_pseudo-client_name -s db2_MultiNode_instance_name -d database_name [-i Commvault_instance_name] -f '04-11-2019 10:00:00' -t'04-11-2019 11:00:00'
Restoring to a disk
Use the following command and options to restore a backup image to a disk:
./db2util.sh -r JOB|LOG -d database_name <[-j jobId] | [-f start_log_sequence_number -t end_log_sequence_number]> [-s source_db2_instance_name] [-p restore_directory] [-c client_name] [-k target pseudo-client name] [-n DPF] [-i Commvault_instance_name]
Restoring to a disk using an input file
Use the following command and options to restore a backup image to a disk by using an input file that includes all the commands.
./db2util.sh -a input_file [-i commvault_instance]
Example
# su - db2inst5
$ cd /opt/Commvault/iDataAgent
./db2util.sh -q all -c DB2DPF_DB2DPFMAC1_1051 -s part1051 -d galaxy -i Instance001
Input:: DBNAME=galaxy
INSTANCE=Instance001
Querying Database: galaxy
QScript[QS_querydb2backup] CS[sc8] DB[CommServ]
Qscript Output:
JOB ID BACKUP TYPE NODE NUMBER TIMESTAMP STREAMS
------ ----------- ----------- -------------- -------
3997465 Full . NODE0000 20170905200118 1
3997465 Full . NODE0001 20170905200115 1
3997465 Full . NODE0002 20170905200132 1
JOB ID NODE NUMBER CHAIN NUMBER FIRST LOG NUMBER LAST LOG NUMBER FIRST LOG TIME LAST LOG TIME
------ ----------- ------------ ---------------- --------------- -------------- -------------
4017701 NODE0002 C0000127 1186 . 1189 . 2017-09-07 16:11:41 2017-09-11 12:29:05
4017701 NODE0001 C0000148 1209 . 1212 . 2017-09-07 16:11:16 2017-09-11 12:25:51
4017701 NODE0000 C0000127 1193 . 1198 . 2017-09-07 16:11:29 2017-09-11 12:26:05Restoring logs
Use the following command to restore a backup image to a disk:
/db2util.sh -r LOG -d database_name [-o target_database_name] [-i Commvault_instance] [-f start_log_sequence_number] [-t end_log_sequence_number] [-c client name][-n DPF]
In the following example, the parameters are on the command line.
/db2util.sh -r LOG -d partdb -o partdb -s part1051 -c DB2DPF_DB2DPFVM1_1051 -i Instance001 -f 390596 -t 390645 -n DPF -k DB2DPF_DB2DPFVM1_1051Restoring by using the log sequence number
./db2util.sh -r LOG -f 1133 -t 1142 -c DB2DPF_DB2DPFMAC1_1051 -s part1051 -d galaxy -i Instance001 -k DB2DPF_DB2DPFMAC1_1051 -n DPFBy default, the software restores the log sequence archive files to the DB2 retrieve path that you specified when you installed the software.