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.
- ### Cr by fubs
- Clear;
- Db2 connect to abbs>/tmp/null;
- Tbname = 'db2 "list tables" | grep-v "record" | awk '{if (length ($1)> 0 & NR> 3) print $1 }'';
- # Declare Variables
- S_date = 'date + % Y-% m-% d, % H: % M: % s'
- V_date = 'date + % Y % m % d'
- Bkpath = $ HOME/personal/fubs/bak/$ v_date;
- If [! -D $ bkpath]; then
- Mkdir $ bkpath;
- Echo "Back up all data, OK? \ C"
- Else
- Echo "has been backed up on the current day. Is it overwritten? \ C ";
- Fi
- Read yn;
- If [-z "$ yn"-o! "$ Yn" = "y"]; then
- Echo "discard operation! ";
- Exit 0;
- Fi
- Cd $ bkpath;
- Num = 0;
- For I in $ tbname
- Do
- Db2 "Export to $ I. del of del select * from $ I ";
- Num = 'expr $ num + 1 ';
- Done
- Db2 connect reset>/tmp/null;
- Db2 terminate>/tmp/null;
- 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