Adsense

Wednesday, April 17, 2013

How to take Online Backup in DB2


Steps for Online Backup in DB2
To do an online table space and database level backup via CLP command prompt, Please follow the steps below.

In order to perform an online backup , you have to Turn on either the LOGRETAIN or USEREXIT .
Command for Turning LOGRETAIN ON :
In this example, i am using database name is as Employee

db2 => update db cfg for Employee using LOGRETAIN on

Now Shutdown and start up the database again to make the configuration change effective
db2 => terminate
db2 => force application all
Now the configuration parameter is effective, you can see LOGRETAIN = RECOVERY

To see wheather the configuration change is effctive , Give the following command

db2 => get db cfg for Employee
Group commit count (MINCOMMIT) = 1
Percent log file reclaimed before soft chckpt (SOFTMAX) = 100
Log retain for recovery enabled (LOGRETAIN) = RECOVERY
User exit for logging enabled (USEREXIT) = OFF

Now We need to do a full offline backup. Otherwise, an error message will be received when trying to connect to the database

db2 => connect to employee
SQL1116N A connection to or activation of database "EMPLOYEE" cannot be made
because of BACKUP PENDING. SQLSTATE=57019

To do full offline backup issue the following commands

db2 =>backup db employee to e:\onlinebkp

Now do the online backup

To do a database level online backup, issue the following command:

db2 => backup database employee online to e:\onlinebkp

Backup successful. The timestamp for this backup image is : 20110529224810

To do Table space level online backup, Give the following command

db2 => backup database employee tablespace(userspace1) online to e:\onlinebkp

Backup successful. The timestamp for this backup image is : 20110529225718

2 comments:

  1. Good explanation, thanks. But as for me, I don't like a command line interface, so I prefer this free simple GUI tool for the PostgreSQL Backup which allow to schedule the backup and store it on a various cloud storage(Dropbox, Google Drive, Amazon S3) or locally. Best Information Management Solutions

    ReplyDelete