The three steps to back up and restore the DB2 database are easy to use!

Source: Internet
Author: User

This article mainly describes the actual operation steps for backing up and recovering the DB2 database. If you are curious about the actual operation steps for backing up and restoring the DB2 database, this article will unveil its secrets, the following is a detailed description of the article.

Database

1. Set archiving parameters:

1. db2 update db cfg for using implements logpath/home/db2inst1/mirror_log // mirror log

2. db2 get db cfg for // check whether it is successful

3. db2 update db cfg for using userexit on // Enable User exit

4. db2 update db cfg for using logretain on // enable archiving logs

5. db2 update db cfg for using trackmod on // enable the Incremental backup function

6. db2stop force

7. db2start

8. After db2 backup db to/home/db2inst1/off_back // starts the preceding parameter, the DB2 database is in the backup pending state and requires offline backup of the database. Otherwise, the SQL1116N error is prompted.

Ii. Back up online databases

9. db2 backup db online to/home/db2inst1/on_back // online backup

10. db2 backup db online incremental to/home/db2inst1/on_back // perform incremental backup online

11. db2 list history backup all for // view backup records

12. db2 get db cfg for // view the location of the log, cp to a secure directory for rollforward use.

13. db2stop force; db2start; db2 drop db // manually drop the database to simulate disaster recovery

3. Restore Online Databases

14. db2ckrst-d-t 20070608032820-r database // The help tool prompts recovery.

15. db2 restore db incremental from/home/db2inst1/on_back taken at 20070608032820 // restore the data file

Recover the full backup first, and then restore the Incremental backup. You cannot automatically find the full backup file.

16. db2 rollforward database to end of logs and complete overflow log path' (/home/db2inst1/log) '// roll back the log

I do not agree: "recover full backup first and then restore Incremental Backup"

For incremental recovery, your practice is reversed. If you do this, you will receive the SQL2574N error message.

In db2ckrst, we have clearly indicated the order of recovery.

The following are the steps to test the backup and recovery of logs in the backup image:

Note:/home/db2inst1/on_back/# indicates the location of the backup file.

/Home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# Is the log location of the DB2 database, which is obtained through db2 get db cfg.

10. db2stop force; db2start; db2 drop db # simulate a disaster and drop the database.

20. db2 backup db online to/home/db2inst1/on_back/include logs # Back up image files with logs

21. db2 backup db online incremental to/home/db2inst1/on_back/include logs # Back up incremental image files with logs

30. db2 RESTORE db incremental automatic FROM/home/db2inst1/on_back/taken at 20070612070526 LOGTARGET/home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# RESTORE data with a timestamp of 20070612070526 images and log files

40. db2 rollforward database to end of logs and complete // roll back log

The database has been dropped in "10". How do I perform online backup in "20?

Note:/home/db2inst1/on_back/# indicates the location of the backup file/home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# indicates the location of the log of the DB2 database, you can use db2 get db cfg.

10. db2 backup db online to/home/db2inst1/on_back/include logs # Back up image files with logs

20. db2 backup db online incremental to/home/db2inst1/on_back/include logs # Back up incremental image files with logs

30. db2stop force; db2start; db2 drop db # simulate a disaster and drop the database.

40. db2 RESTORE db incremental automatic FROM/home/db2inst1/on_back/taken at 20070612070526 LOGTARGET/home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR/# RESTORE data with a timestamp of 20070612070526 images and log files

50. db2 rollforward database to end of logs and complete // roll back log

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.