How to back up all tables in DB2

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

The backup method described below is used to back up data in all tables in DB2. If you have encountered similar problems in backing up all tables in DB2, take a look.

 
 
  1. ### Cr by fubs
  2. Clear;
  3. Db2 connect to abbs>/tmp/null;
  4. Tbname = 'db2 "list tables" | grep-v "record" | awk '{if (length ($1)> 0 & NR> 3) print $1 }'';
  5. # Declare Variables
  6. S_date = 'date + % Y-% m-% d, % H: % M: % s'
  7. V_date = 'date + % Y % m % d'
  8. Bkpath = $ HOME/personal/fubs/bak/$ v_date;
  9. If [! -D $ bkpath]; then
  10. Mkdir $ bkpath;
  11. Echo "Back up all data, OK? \ C"
  12. Else
  13. Echo "has been backed up on the current day. Is it overwritten? \ C ";
  14. Fi
  15. Read yn;
  16. If [-z "$ yn"-o! "$ Yn" = "y"]; then
  17. Echo "discard operation! ";
  18. Exit 0;
  19. Fi
  20. Cd $ bkpath;
  21. Num = 0;
  22. For I in $ tbname
  23. Do
  24. Db2 "Export to $ I. del of del select * from $ I ";
  25. Num = 'expr $ num + 1 ';
  26. Done
  27. Db2 connect reset>/tmp/null;
  28. Db2 terminate>/tmp/null;
  29. Echo "the data has been backed up successfully. A total of [$ num] database tables have been backed up! "

How to Implement DB2 row-to-column Conversion

DB2 offline backup test instance

Implementation of deleting duplicate data in DB2

Abnormal DB2 uninstall Method

Four ways to delete DB2 data

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.