db2 backup and restore

Backup and restore should be one of the 1st lines of defense that a System administrator uses.

Basic backup

   db2 backup database Bob online to 
/home/db2inst1/onlinebackup/ compress include logs    

Check the Backup is Ok

A backup without a check - is more of a hope/prayer....

db2ckbkp <location/backup file>  

db2 restore

You accidentally delete some records or drop a table.... time to bring the database back.

db2 restore database <db_name> from <location> 
taken at <timestamp> 


db2 restore database bob from /home/db2inst1/ taken at 

db2restore to a new name

Restore a database as a new name - and keep do not touch the original.

mkdir -p /home/db2inst1/db2inst1/NODE0000/BOB
mkdir -p /home/db2inst1/db2inst1/NODE0000/SQL00004/LOGSTREAM0000/

db2 restore database TIM from /home/db2inst1/backup/ taken at 20171005040109 to 
/home/db2inst1/db2inst1/NODE0000/BOB INTO BOB  NEWLOGPATH /home/db2inst1/db2inst

This will create a new database called BOB from a backup called TIM.

You need to see which directories are free i.e. the SQL0004 will vary each time.

db2 restore will give you a warning if you are going to overwrite an existing database.