Option 2 - Using Scripts

You can use DB2 commands in a script to achieve the same goal. The script method is recommended because it facilitates specifying the environment variables and allows for greater flexibility.

To back up the database, enter the db2 backup command in your script. The backup statement should specify the shared library libbexdb2-shared.a.64 for UNIX or bexdb2.dll for Windows by using the load parameter. The following three customizable parameters of the backup statement should be considered for performance optimization:

  • BUFFERSIZE (default = 4096 per page)

  • NUMBER OF BUFFERS (default = 4)

  • NUMBER OF SESSIONS (default = 1)

The following is a UNIX example of a DB2 backup script, which includes environment settings as well as the db2 backup statement:

#!bin/sh  
INSTHOME=/export/home/db2inst1; export INSTHOME  
SSPRODIR=/export/home/techsupp/BEX214d; export SSPRODIR  
LD\_LIBRARY\_PATH=$SSPRODIR/lib:$LD\_LIBRARY\_PATH; export LD\_LIBRARY\_PATH  
PATH=$SSPRODIR:$SSPRODIR/bin:$PATH; export PATH  

\# db2 ‑v backup database mydb1 load $SSPRODIR/lib/libbexdb2-shared.a.64 
open 1 sessions

echo done

The DB2 installation program for UNIX generates the sample script db2backup, which is in the bin subdirectory of the directory in which DPX is installed, similar to the one above. You can edit the sample script and then use it as your DB2 backup script in the INSTHOME directory.

Note. The script displayed above is an example of how to invoke DB2 support on DB2 UDB EE. On the Extended Enterprise version (EEE), backups can be run simultaneously on multiple nodes using the db_all command.

Last updated