wait for my house to look like something from the Flinstones,
and am making sure that all of my disaster recovery ducks
are in a row, I though maybe someone could use my linux-based
script that backs up DB2 configuration data, which I call
"lifeboat".
Just put your own info anywhere you see UPPERCASE text in
<> brackets. I store everything in /db2/lifeboat/...
As a final step, the script scp's the config info to another
server for safekeeping. I run this on a cron - if you do,
don't forget to ssh-keygen to generate your SSH public key.
This, combined with your standard DB2 backups all stored in
a safe place, should make it far easier to recover from
disaster.
Cheers
Allen W. Jantzen, DBA
Ned Davis Research
--------------------------------
#start lifeboat.sh
for instance in <PUT INSTANCE HERE>
do
cd /db2/lifeboat/<HOSTNAME>/instance/$instance
# get instance cfg
echo `date` > $instance.cfg
db2 -v get dbm cfg >> $instance.cfg
# get db directory
echo `date` > db_directory.txt
db2 -v list database directory >> db_directory.txt
# get db2set
echo `date` > db2set.txt
db2set >> db2set.txt
done
for db in <LIST DATABASES HERE, SEPARATED BY SPACES>
do
cd /db2/lifeboat/<HOSTNAME>/database/$db
# get db cfg
echo `date` > $db.cf
db2 get db cfg for $db >> $db.cfg
echo `date` > backup_history.txt
db2 -v list history backup all for db $db >> backup_history.txt
db2 -v connect to $db
echo `date` > tablespace.txt
db2 -v list tablespaces show detail >> tablespace.txt
echo `date` > containers.txt
for tsid in `cat tablespace.txt | grep "Tablespace ID" | awk
'{print $4}'`
do
db2 -v list tablespace containers for $tsid show detail
containers.txt
done
echo `date` > tables.txt
db2 -v list tables for all >> tables.txt
echo `date` > table_structure.txt
for tableandschema in `cat tables.txt | awk '(NR > 5) {print
$0}' | grep -v "^ " | grep -v "^$" | awk '{print $2"."$1}'`
do
db2 -v describe table $tableandschema >>
table_structure.txt
done
echo `date` > table_indexes.txt
for tableandschema in `cat tables.txt | awk '(NR > 5) {print
$0}' | grep -v "^ " | grep -v "^$" | awk '{print $2"."$1}'`
do
db2 -v describe indexes for table $tableandschema >>
table_indexes.txt
done
echo `date` > table_sql.txt
db2look -d $db -e -a -xd | sed 's/NOT LOGGED INITIALLY//g' >>
table_sql.txt
echo `date` > $db.bpools.txt
db2look -d $db -l >> $db.bpools.txt
echo `date` > $db.db2look.cfg
db2look -d $db -f >> $db.db2look.cfg
echo `date` > packages.txt
db2 -v list packages for all >> packages.txt
db2 -v connect reset
db2 -v terminate
echo `date` > filesystem.txt
ls -lR /containers/$db >> filesystem.txt
done
cd /db2/lifeboat
scp -r <ANOTHER HOSTNAME>:/db2/lifeboat/<HOSTNAME> .