DB2 - SPLessons

DB2 Backup and Restore

Home > Lesson > Chapter 23
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

DB2 Backup and Restore

DB2 Backup and Restore

shape Description

Backup and recovery strategies are intended to preserve the data secure. In Graphical User Interface (GUI) or Command Line Interface (CLI) utilizing backup and recovery utilities and can perform the backup or reestablish the information of databases in DB2 UDB.

DB2 Backup

shape Description

DB2 Database Backup command can duplicate the whole database. This backup duplicate incorporates the database informational files, controlled information system records, log records. A DB2 Backup consisting of:

Offline backup

shape Description

For performing offline backup activate the applications in each and every database contain in the DB2.

shape Syntax

The syntax for offline backup is as follows:
db2 list application List application => List all the applications inside the DB2 database.

shape Examples

By viewing the below example, the concept of offline backup can be easily understands. [c] db2 => create database hope DB20000I The CREATE DATABASE command completed successfully. db2 => connect to hope Database Connection Information Database server = DB2/NT64 11.1.0 SQL authorization ID = KALYAN.V... Local database alias = HOPE db2 => LIST APPLICATION Auth Id Application Appl. Application Id DB # of Name Handle Name Agents -------- -------------- ---------- --------------------------------------------- ----------------- -------- ----- KALYAN.> db2bp.exe 1609 *LOCAL.DB2.160910041329 HOPE 1 db2 => force application DB20000I The FORCE APPLICATION command completed successfully. [/c]

Online backup

shape Description

For performing online backup first change the mode from Circular logging to Archive Logging.

shape Syntax

The syntax for online backup is as follows:
db2 get db cfg for one | grep LOGARCH

shape Examples

By viewing the below example, the concept of online backup can be easily understands. [c] db2 => Get db cfg for one | grep LOGARCH First log archive method (LOGARCHMETH1) = OFF Archive compression for logarchmeth1 (LOGARCHCOMPR1) = OFF Options for logarchmeth1 (LOGARCHOPT1) = Second log archive method (LOGARCHMETH2) = OFF Archive compression for logarchmeth2 (LOGARCHCOMPR2) = OFF Options for logarchmeth2 (LOGARCHOPT2) = ON [/c]

shape Conceptual figure

The below conceptual keys shows the DB2 Backup and Restore.

DB2 Restore

shape Description

For restoring a database from backup all the necessary commands has to be performed for backing up the DB2 database.

shape Syntax

The syntax for recovering a DB2 database is as follows:
Restore database <db_name> from <location> taken at <timestamp> Restore => Restore the database. db_name => Name of the database. Location => Place where the backup is choosen.

shape Examples

By viewing the below example, the concept of recovering the DB2 database can be easily understands. [c]db2 restore database one from /home/db2inst1/ taken at 20140722112743 SQL2523W Warning! Restoring to an existing database that is different from the database on the backup image, but have matching names. The target database will be overwritten by the backup version. The Roll-forward recovery logs associated with the target database will be deleted. Do you want to continue ? (y/n) y DB20000I The RESTORE DATABASE command completed successfully. db2 rollforward db one to end of logs and stop Rollforward Status Input database alias = one Number of members have returned status = 1 Member ID = 0 Rollforward status = not pending Next log file to be read = Log files processed = S0000000.LOG - S0000001.LOG Last committed transaction = 2014-07-22- 06.00.33.000000 UTC DB20000I The ROLLFORWARD command completed successfully. [/c]

Summary

shape Key Points

  • DB2 Backup and Restore - Are intended to preserve the data safe and secure.
  • DB2 Backup - Can make a duplicate copy of database records and documents.
  • Offline Backup - Activate the applications in the database.
  • Online Backup - Have to change the mode from circular logging to archieve logging.
  • DB2 Recovering - Recovering the DB2 database.