DB2 backup procedure

The below script-let will backup the DB2 config , DB and DB Config by getting the DB names dynamically.

Here
<BACKUP_DIR> can be any folder where you want to place the backups.
<INSTANCE_NAME> is db instance name.

for DB_NAME in `db2 list db directory |grep -ip indirect |grep -i alias |awk '{print $4}'`
do
            echo "DB_NAME: ${DB_NAME}"
            db2 connect to ${DB_NAME}
            db2 backup database ${DB_NAME} to <BACKUP_DIR>
            db2 list tablespaces show detail > <BACKUP_DIR>/tablespaces.out
            db2 get db cfg for ${DB_NAME} show detail > <BACKUP_DIR>/dbcfg.out
            db2support <BACKUP_DIR> -d ${DB_NAME}
done
       
db2 force applications all
db2 terminate
db2stop
/home/${INSTANCE_NAME}/sqllib/bin/ipclean

db2set -all > <BACKUP_DIR>/db2set.out
set > <BACKUP_DIR>/set_env.out
env >> <BACKUP_DIR>/set_env.out
db2licm -l > <BACKUP_DIR>p/licm_level.out
db2level >> <BACKUP_DIR>/licm_level.out
db2 get dbm cfg show detail> <BACKUP_DIR>/dbmcfg.out
db2 list db directory > <BACKUP_DIR>/dbdirectory.out
db2 list node directory > <BACKUP_DIR>/dbnodedirectory.out
   



Comments

Popular posts from this blog

Jenkins Dynmaic Parameter - List All Branches in a Git Repository

JMSWMQ2013: The security authentication was not valid that was supplied for QueueManager 'XYZ' with connection mode 'Client' and host name 'x.x.x.x(1415)'. Please check if the supplied username and password are correct on the QueueManager to which you are connecting.