Db2 Backup Recovery

Source: Internet
Author: User

 

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 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 // recover the full backup of the data file first, and then restore the incremental backup, and cannot automatically find the full backup file.

16. db2 rollforward database to end of logs and complete overflow log path' (/home/db2inst1/log) '// The rollback log does not agree with the following: "recover full backup first, then you are recovering incremental backup. "for incremental recovery, your practice is reversed. If you do this, you will receive an error message from SQL2574N. In db2ckrst, we have clearly indicated the order of recovery. Follow these 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/# indicates the location of the database log, 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 // The rollback log has dropped the database in "10". How does one 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 database log, 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.