Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / October 2005

Tip: Looking for answers? Try searching our database.

A pre-Wilma freebie for the DB2 crowd

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
aj - 19 Oct 2005 21:08 GMT
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> .
Philip Nelson - 19 Oct 2005 23:02 GMT
> 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,
[quoted text clipped - 18 lines]
> 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
aj - 20 Oct 2005 14:07 GMT
Philip -

A good suggestion - thanks.

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,
[quoted text clipped - 33 lines]
> Phil Nelson
> ScotDB Limited
2803stan@gmail.com - 30 Oct 2005 00:16 GMT
Hi aj,

Thanks for your script and for Philip's suggestion.

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

SS
hikums@gmail.com - 31 Oct 2005 16:24 GMT
Backup database does not capture anything outside of DB such as
instance config, db2set, os level etc...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.