You can use the db2util.ps1 utility on Windows to query, and then restore the backup images to a disk. You must be a valid DB2 user to run this DB2 Utility. The CommCell 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
cd software_installation_directory/Base qlogin -cs commserve_name -u commcell_user_name -p commcell_login_password -
Start the PowerShell prompt.
You can type PowerShell from the Windows prompt or you can start it from the command line prompt.
-
Enable the PowerShell script execution on the system:
set db2instance=db2_instance_name powershell powershell Set-ExecutionPolicy Unrestricted -
Type the following command to get the usage information.
PS C:\software_installation_directory\iDataAgent> db2util.ps1For 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.ps1 -q LOG | DATA | ALL -d db2_database_name [-s db2_instance_name] [-c 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.ps1 -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] [-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 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 to restore a backup image to a disk:
db2util.ps1 -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] [-n DPF] [-i Commvault_instance_name]
Restoring the logs
Use the following command to restore a backup image to a disk:
db2util.ps1 -r LOG -d database_name [-o target_database_name] [-i Commvault_instance_name] [-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.ps1 -r LOG -d partdb -o partdb -s part1051 -c DB2DPF_DB2DPFVM1_1051 -i Instance001 -f 390596 -t 390645 -n DPF -k DB2DPF_DB2DPFVM1_1051Restoring to a disk using an input file
Use the following command to use an input options file which include all the query and restore commands for execution:
db2util.ps1 -a option file [-i Commvault_instance]
Example
PS C:\Program Files\CommVault\ContentStore\iDataAgent> .\db2util.ps1 -q all -d testdb -i Instance001
Input:: DBNAME=testdb INSTANCE=Instance001
Querying Database: testdb
QScript[QS_querydb2backup] CS[dbserve20] DB[CommServ] SP[QS_querydb2backup]
Qscript Output:
jobId bkupLevel NodeNumber timeStamp streams
----- --------- ---------- --------- -------
Qscript Execution Succeeded!
QScript[QS_querydb2backup] CS[dbserve20] DB[CommServ] SP[QS_querydb2backup]
Qscript Output:
jobId nodeNumber chainNumber firstLogNumber lastLogNumber firstLogTime lastLogTime
----- ---------- ----------- -------------- ------------- ------------ -----------
Qscript Execution Succeeded!
PS C:\Program Files\CommVault\ContentStore\iDataAgent> .\db2util.ps1 -q a -d testdb30 -i Instance001
Input:: DBNAME=testdb30 INSTANCE=Instance001
Querying Database: testdb30
QScript[QS_querydb2backup] CS[dbserve20] DB[CommServ] SP[QS_querydb2backup]
Qscript Output:
jobId bkupLevel NodeNumber timeStamp streams
----- --------- ---------- --------- -------
2742 Full NODE0000 20130204124812 1
2745 Incr NODE0000 20130204125352 1
2748 Delta NODE0000 20130204125907 1
2763 Full NODE0000 20130204133429 1