Database

DB2 Backup using TSM

In this example we are using a DB2 database called WPSDB. At one point I needed to automate a backup from DB2 into Tivoli Storage Manager. IBM Tivoli Storage Manager is a data backup platform that gives enterprises a single point of control and administration for storage management needs.

Get current config:

db2 => connect to WPSDB
db2 => GET DATABASE CONFIGURATION

There will be a big long list and you are trying to find LOGARCHMETH1.

First log archive method (LOGARCHMETH1) = OFF
Options for logarchmeth1 (LOGARCHOPT1) =
Second log archive method (LOGARCHMETH2) = OFF

Now let’s change this into TSM:

db2 => update db cfg using LOGARCHMETH1 TSM
DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully.
SQL1363W One or more of the parameters submitted for immediate modification
were not changed dynamically. For these configuration parameters, all
applications must disconnect from this database before the changes become
effective.

At this point ignore warning messages.
Let’s look if the change was OK:

db2 => GET DATABASE CONFIGURATION FOR WPSDB

First log archive method (LOGARCHMETH1) = TSM
Options for logarchmeth1 (LOGARCHOPT1) =
Second log archive method (LOGARCHMETH2) = OFF
Options for logarchmeth2 (LOGARCHOPT2) =
Failover log archive path (FAILARCHPATH) =
Number of log archive retries on error (NUMARCHRETRY) = 5
Log archive retry Delay (secs) (ARCHRETRYDELAY) = 20
Vendor options (VENDOROPT) =

Look for “First log archive method (LOGARCHMETH1)” parameter. It should now be set to “TSM”.

Restart DB2 instance:

db2 force applications all
db2 terminate
db2stop

Start DB/2

db2start

Run full DB2 backup manually as administrator:

db2 backup db WPSDB use tsm
Backup successful. The timestamp for this backup image is : 20140411144830

Proceed with enabling automated DB2 TSM backup by creating a administrative schedule that call the script (db2backup_full.cmd). You can then schedule this backup from TSM:

set DB2INSTANCE=DB2
"C:\IBM\ProductName\db2\BIN\db2cmd.exe" /c DB2.EXE backup db WPSDB user <DOMAINUSERNAME> using <DOMAINUSERPASSWORD> online use tsm include logs

So there you go, we now have a DB2 backup using TSM and it’s working automatically.