Detailed drill of DB2 Incremental Backup Recovery

Source: Internet
Author: User
Tags db2 connect db2 connect to

DB2 supports Incremental Backup (Incremental Backup) and Delta Backup (Delta Backup. incremental backup is equivalent to a differential backup in Oracle, that is, after a full backup, all the changes since the full backup are backed up for each other Incremental backup. delta backup is equivalent to Incremental Backup in Oracle. Each Incremental Backup only backs up the incremental parts since the previous backup. A detailed Incremental Backup example is provided below. delta backup is similar. To test the backup, you only need to change "incremental" in the BACKUP command to "incremental delta. for the manual one-step recovery of Delta backup, refer to the order of the db2ckrst command. -- $ db2level DB21085I Instance "db2inst1" uses "64" bits and DB2 code release "SQL09010" with level identifier "02010107 ". informational tokens are "DB2 v9.1.0.0", "s060629", "AIX64", and Fix Pack "0 ". product is installed at "/opt/db2_09_01 ". su-db2inst1 cd/home/db2inst1/mkdir db2bk1 db2bk2 db2logs -- enable user exit db2 update db cfg for xcldb using userexit on -- enable archive log db2 update db cfg for xcldb using logretain on -- enable the Incremental backup function db2 update db cfg for xcldb using trackmod on -- make an offline backup db2 backup db xcldb to/home/db2inst1/db2bk1

For details about how to create a test database, see: manually create a database in DB2.

The Incremental Backup test plan backs up db2 connect to xcldb for the first time -- db2 "drop table t_x01" -- db2 "drop table t_x02" db2 "create table t_x01 like syscat. tables "db2 connect reset -- one full backup, subsequent incremental backups will be based on this full backup 20131216230354 db2 backup db xcldb online to/home/db2inst1/db2bk2 include logs for the second backup db2 connect to xcldb db2 "insert into t_x01 select * from syscat. tables "db2" select count (*) from t_x01 "db2 connect reset -- backup contains logs, remember to manually back up the logs. 20131216230432 db2 backup db xcldb online incremental to/home/db2inst1/db2bk2 include logs for the third backup-Modify the data db2 connect to xcldb db2 "create table t_x02 like syscat. tables "db2" insert into t_x02 select * from syscat. tables "db2" select count (*) from t_x02 "db2 connect reset -- backup includes log 20131216230506 db2 backup db xcldb online incremental to/home/db2inst1/db2bk2 include logs fourth backup -- delete table t_x01 db2 connect to xcldb db2" drop table t_x01 "db2 connect reset -- 20131216230624 db2 backup db xcldb online incremental to/home/db2inst1/db2bk2 include logs ----

View the backup file [db2inst1 @ O11g64 ~] $ Ls-l/home/db2inst1/db2bk2/total 134648-rw-r -----. 1 db2inst1 db2iadm1 55795712 Dec 16 XCLDB.0.db2inst1. node).catn2017.20131216230354.001-rw-r -----. 1 db2inst1 db2iadm1 9863168 Dec 16 XCLDB.0.db2inst1. node).catn2017.20131216230432.001-rw-r -----. 1 db2inst1 db2iadm1 36110336 Dec 16 XCLDB.0.db2inst1. node).catn2017.20131216230506.001-rw-r -----. 1 db2inst1 db2iadm1 36110336 Dec 16 XCLDB.0.db2inst1. node).catn316.20131216230624.001 -- view the backup history db2 list history backup all for xcldb -- Obtain the recovery sequence db2ckrst-d xcldb-t 20131216230506-r database ------

Delete database db2 drop db xcldb ----

Database recovery: method 1 of database recovery for the third backup: db2 restore database xcldb incremental automatic from/home/db2inst1/db2bk2 taken at 20131216230506 logtarget/home/db2inst1/db2logs restore database Method 2: ls/home/db2inst1/db2bk2 db2 "restore db xcldb incremental from/home/db2inst1/db2bk2 taken at 20131216230506" db2 "restore db xcldb incremental from/home/db2inst1/db2bk2 taken at 20131216230354 "db2" restore db xcldb incremental from/home/db2inst1/db2bk2 taken at 20131216230506 logtarget/home/db2inst1/db2logs "Check recovery: -- check whether logs are restored on the current day. ls/home/db2inst1/db2logs -- check the database status and the required logs. db2 rollforward db xcldb query status roll-forward Method 1: -- get the log directory db2 get db cfg for xcldb -- Path to log files/home/db2inst1/db2inst1/NODE0000/SQL00002/SQLOGDIR/-- get the specified directory cp/home/db2inst1/db2logs/ */home/db2inst1/db2inst1/NODE0000/SQL00002/SQLOGDIR/ls/home/db2inst1/db2inst1/NODE0000/SQL00002/SQLOGDIR/-- roll forward */db2 "rollforward db xcldb to end of logs and complete "Method 2: if you do not copy logs, directly specify the Directory and then roll db2 "rollforward db xcldb to end of logs and complete overflow log path ('/home/db2inst1/db2logs')" -- check results: because it is the third Backup recovery, both tables should have records of db2 connect to xcldb db2 "select count (*) from t_x01" db2 "select count (*) from t_x02 "db2 connect rest -- now the Backup recovery is complete.

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.