README_DB2.txt
-------------

db2_export.sh and db2_fast_import.sh scripts must be executed from DB2 server using DB2 instance owner userid.

*************************
db2_export.sh
*************************
db2_export.sh exports a WPC schema and all it's components using db2move utility. It also generates required sql scripts to create tables, indexes and sequences with current values. It exports everything, compress using gzip utility then stores it as a tar file in the backup directory provided. 

Syntax:
db2_export.sh --db=<databasename> --dbuser=<exportuser> --dbpassword=<exportuserpassword> --backupdir=<bkpdirectory> --bkpfile=<bkpfilename>

databasename: Name of the database from where you want to export the schema

exportuser: Name of the WPC db schema user to export. It is db_userName in common.properties file.

dbuserpassword: Password of the WPC db schema user that is getting exported. It is db_password in common.properties file.

bkpdirectory: Name of the directory including PATH where you want to export the database schema. (Where you want to create the dump tar file)

bkpfilename: Name of the backup tar file

For example:
db2_export.sh --db=wpcdb --dbuser=wpc1 --dbpassword=ibm4wpc --backupdir=/u01/backup --bkpfile=july10bkp

Note:
1. Make sure that the db2_export.sh script is saved in Unix format if it is copied from your Windows laptop or desktop to the db server. 
   Otherwise system can introduce end of line characters that makes this script fail.

2. If you want to take a logical backup of your db schema please get help from a DB2 DBA.
   If you are not sure about whom to contact to get DBA's help, please contact IBM WPC Support team at wpcsupt@us.ibm.com

Pre-requisites:
1. Shutdown the WPC application connected to the db schema that is getting exported before running db2_export.sh 
2. Make sure that the backup directory exists and the path is correct. Make sure that the owner of the backup directory is db2 instance owner on the db server (for example db2inst1)
3. Never use a directory which has db2 data files (SMS and DMS files) as the backup directory.
4. Make sure that the backup directory is created on local disks on the db server (not NFS)

      
*************************
db2_fast_import.sh 
*************************

db2_fast_import.sh uses the contents of the tar file that is generated by db2_export.sh and imports it into the database for a new Dev or QA environment.
You can use this script to import the schema into the same database under the same or a different schema name OR into a different database with the same 
or different schema name.

WARNING
-------
If you are importing into a schema that already exists that has WPC or other tables, all tables will be dropped. 

Syntax:
db2_fast_import.sh --db=<databasename> --dbuser=<touser> --dbpassword=<touserpassword> --backupdir=<DumpDirectory>

databasename: Name of the database into which you are importing the schema. It can be the same database from which you exported a schema.

touser: Name of the db user into which you want to import the tables, indexes, sequences etc.

touserpassword: Password of the empty db user into which you are importing the schema

dumpdirectory: Directory in which the tar file is uncompressed. In this directory you will see all the dump files and sql scripts that are crated by db2_export.

For example:
db2_fast_import.sh --db=wpcdb --dbuser=trigodev --dbpassword=trigodev --backupdir=/u01/backup/july10/july10bkp

Note:
Make sure that the db2_fast_import.sh script is saved in Unix format if it is copied from your Windows laptop or desktop to the db server. 
Otherwise system can introduce end of line characters that makes this script fail.


Pre-requisites (if you want to import to a new db user):
--------------------------------------------------------
1. Create new empty db user at o/s and db level and grant all privileges before you import the schema into this new user.
     Name of the user can't exceed 8 characters in length.

1a. Create user at O/S level

You can use smitty (AIX utility) or "useradd" to create the new user on the database server.

For example:
   
useradd -g db2grp1 -md /home/wpcdev wpcdev
passwd wpcdev

On AIX make sure you login to database server using trigodev user (new user) using a new telnet session once because you will be asked to change the password for the first time when you login on AIX.

1b. Create db user at database level and grant the privileges in the database

Refer to installation guide for granting the privileges and creating an empty user schema.

2. Uncompress and untar the tar file into a local directory and make sure that the directory where the tar is uncompressed is owned by db2 instance owner. 

For example: (Let us assume that tar file is compressed and it's name is july10bkp.tar.gz)

su - db2inst1
mkdir /u01/backup/july10
cp july10bkp.tar.gz /u01/backup/july10
cd /u01/backup/july10
gunzip july10bkp.tar.gz
tar -xvf july10bkp.tar
(This tar command will uncompress the tar file and put it's contents in /u01/backup/jul10/jul10bkp directory)

3. Make sure that there are no errors at the time of export. You can check the EXPORT.out for any errors that are generated during export. 
   If there are any errors during export then you can't use the dump for import. 
   Correct the error, re-export the database schema using db2_export.sh  and try the import.

4. Make sure there is enough space in the tablespaces before importing the database schema.
    Use "db2 list tablespaces show detail" command to check the available space in the tablespaces. Add more space if needed.

