top of page

DB2 Backup and Recovery Cheat Sheet

  • Writer: Jha Chandan
    Jha Chandan
  • Oct 8, 2021
  • 2 min read

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.

ree

In this blogpost you will see and learn Db2 Bufferpools related syntaxes and methods which help you using Db2 database product.


DB2 Database Backup

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:

  1. Offline backup

  2. Online backup

Offline backup


List the active applications/databases

db2 list application  

Terminate Database Connection

db2 terminate 

Deactivate Database

db2 deactivate database testdb   

Take the backup file

db2 backup database <db_name> to <location>   

Online backup

Check if the database is using circular or archive logging

db2 get db cfg for testdb | grep LOGARCH   

Updating logarchmeth1 with required archive directory

Make directories

mkdir OnlineBackup 
mkdir OnlineBackup/ArchiveDest   

Provide user permissions for folder

chown db2inst1:db2iadm1 OnlineBackup/ArchiveDest 

Update configuration LOGARCHMETH1

db2 update database configuration for testdb using LOGARCHMETH1'DISK:/home/db2inst1/OnlineBackup/ArchiveDest'

Take online backup

db2 backup database testdb online to 
/home/db2inst1/OnlineBackup/ compress include logs  

Verify Backup

db2ckbkp <location/backup file>   

Listing the history of backup files

db2 list history backup all for testdb

DB2 Database Restore

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

Restore the database from backup file

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

Roll forward all the logs located in the log directory, including the latest changes just before the disk drives failure.

db2 rollforward db <db_name> to end of logs and stop 

That's all in this post. If you liked this blog and interested in knowing more about IBM Db2. Please Like, Follow, Share & Subscribe to www.ImJhaChandan.com.

Comments


jc_logo.png

Hi, thanks for stopping by!

Welcome to my “Muse & Learn” blog!
Muse a little, learn a lot.✌️

 

Here you’ll find practical SQL queries, troubleshooting tips with fixes, and step-by-step guidance for common database activities. And of course, don’t forget to pause and muse with us along the way. 🙂
 

I share insights on:​​

  • Db2

  • MySQL

  • SQL Server

  • Linux/UNIX/AIX

  • HTML …and more to come!
     

Whether you’re just starting out or looking to sharpen your DBA skills, there’s something here for you.

Let the posts
come to you.

Thanks for submitting!

  • Instagram
  • Facebook
  • X
2020-2025 © TechWithJC

Subscribe to Our Newsletter

Thanks for submitting!

  • Facebook
  • Instagram
  • X

2020-2025 © TechWithJC

bottom of page