DB2離線備份最簡單的命令可以是這樣:db2 backup db sample to c:\db2bak 但實際做定時備份時哪這麼簡單,我整理了UNIX/Linux及Windows下做定時離線備份的腳本. 很好用的. UNIX/Linux: 1. 新建目錄並授權以便存放備份文件 [root@O11g64 tmp]# id db2inst1 uid=1051(db2inst1) gid=1010(db2iadm1) groups=1010(db2iadm1),1020(db2fadm1) mkdir /db2bak chown -R db2inst1:db2iadm1 /db2bak 2. 新建BAT文件db2bkoffline.sh
#author:xiongchuanliang #停頓數據庫 db2 connect to xcldb db2 quiesce database immediate force connections db2 connect reset #斷開所有應用 db2 force application all #離線備份 db2 backup db xcldb to "/db2bak" with 2 buffers buffer 1024 parallelism 1 without prompting #取消數據庫停頓 db2 connect to xcldb db2 unquiesce database db2 connect reset exit
;;author:xiongchuanliang ;;停頓數據庫 db2 connect to xcldb db2 quiesce database immediate force connections db2 connect reset ;;斷開所有應用 db2 force application all ;;離線備份 db2 backup db xcldb to "c:\\db2bak" with 2 buffers buffer 1024 parallelism 1 without prompting ;;取消數據庫停頓 db2 connect to xcldb db2 unquiesce database db2 connect reset exit;2. 運行備份 db2cmd /c /w /i db2bkoffline.bat >> c:\\db2bkoffline.log