By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,756 Members | 1,745 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,756 IT Pros & Developers. It's quick & easy.

A pre-Wilma freebie for the DB2 crowd

P: n/a
aj
I'm on the west coast of Florida south of Tampa, and as I
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> .
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
aj wrote:
I'm on the west coast of Florida south of Tampa, and as I
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


Allen,

A useful script.

I have one suggestion.

Running the db2support command gathers a lot of information about your
system. It will contain a lot of what you've gathered. Maybe you want to
look into running that as part of your process.

HTH

Phil Nelson
ScotDB Limited

Nov 12 '05 #2

P: n/a
aj
Philip -

A good suggestion - thanks.

aj

Philip Nelson wrote:
aj wrote:

I'm on the west coast of Florida south of Tampa, and as I
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

Allen,

A useful script.

I have one suggestion.

Running the db2support command gathers a lot of information about your
system. It will contain a lot of what you've gathered. Maybe you want to
look into running that as part of your process.

HTH

Phil Nelson
ScotDB Limited

Nov 12 '05 #3

P: n/a
Hi aj,

Thanks for your script and for Philip's suggestion.

But . . . What more do these methods have above BACKUP DATABASE?

SS

Nov 12 '05 #4

P: n/a
Backup database does not capture anything outside of DB such as
instance config, db2set, os level etc...

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.