Steps and operations for implementing DB2 Backup Recovery

Source: Internet
Author: User

The following article mainly introduces some questions about DB2 Backup Recovery in actual operations. If you are curious about DB2 Backup recovery, the following article will unveil its mystery, the following is a description of the specific content. I hope it will be helpful for your future study.

After practicing DB2 backup and recovery, the online DB2 backup was successfully restored after several days.

Let me explain how I did it first.

Create a database testdb

 
 
  1. db2 create database testdb using codeset UTF-8 territory US 

Enable online backup

 
 
  1. db2 update db cfg for testdb using userexit on logretain on trackmod on 

Create Backup Directory

 
 
  1. mkdir /backup/db2inst1  
  2. chown db2inst1:db2grp1 /backup/db2inst1 

Restart the db2 instance for a cold backup with a timestamp of 20100224111110

 
 
  1. db2stop force  
  2. db2start  
  3. db2 backup db testdb to /backup/db2inst1 

Create a database table

 
 
  1. create table T(  
  2. a int,  
  3. b int,  
  4. c int  

Insert 100 data records in table T, 0, 0

Online backup with a timestamp of 20100224113029

 
 
  1. db2 backup db testdb online to /backup/db2inst1 

View the first activity log, S00000001.LOG

 
 
  1. db2 get db cfg for testdb 

Insert 100 data records in table T, 1

Online backup with a timestamp of 20100224113530

 
 
  1. db2 backup db testdb online to /backup/db2inst1 

View the first activity log, S0000002.LOG

 
 
  1. db2 get db cfg for testdb 

Delete 100, 0, 0

Copy all the archived logs and activity logs in the SQLOGDIR directory to the/temp directory.

Delete the entire testdb

 
 
  1. db2 drop db testdb 

DB2 Backup recovery to the last backup point 20100224113530

 
 
  1. db2 restore database testdb from /backup/db2inst1 taken at 20100224113530 

Copy all archived logs and activity logs to SQLOGDIR and change users and user groups.

 
 
  1. chown db2inst1:db2grp1 * 

Log rollback

Because the backup timestamp date and the archiving log time seem a little different, my current practice is to first execute the following sentence to get a time, then rollforward can be rolled back at that time.

 
 
  1. db2 rollforward db testdb stop 

After executing the preceding statement, the following message is displayed:

 
 
  1. SQL1276N Database "TESTDB" cannot be brought out of rollforward pending state   
  2. until roll-forward has passed a point in time greater than or equal to   
  3. "2010-02-24-03.12.34.000000 UTC", because node "0" contains information later  

Than the specified time.

According to the prompts, get the time 2010-02-24-03.12.34.000000, and then rollforward to this time.

 
 
  1. db2 rollforward db testdb to 2010-02-24-03.12.34.000000 and stop 

I don't know. Under normal circumstances, how do masters know when to roll back? For more information, see. Thank you!

I also found a situation during rollback: according to the activity log, DB2 backup can be used to restore the data between the fault point and the last backup point.

Write more time points later in rollforward.

 
 
  1. $ Db2 rollforward db testdb to 2010-02-24-03.15.00 and stop
  2. Then he will prompt SQL4970N Roll-forward recovery on database "TESTDB" cannot reach
  3. Specified stop point (end-of-log or point-in-time) on database partition (s)
  4. "0". Roll-forward recovery processing has halted on log file "S0000005.LOG ".

At this time, the database is still in pending state. If you execute db2 rollforward db testdb stop again, the DB2 backup can be restored to the State before the database is deleted.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.