Db2 automatic backup script

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

Db2 automatic backup script

#! /Bin/bash # db2 automatic backup script # create at 2013-07-24 # ------------------------- # parameter dblist1 = BOYA # Database dblist2 to be backed up = BOYACZbkrootpath = ~ /Backup # backup path bkdate = 'date + % Y % m % d' # backup time bkpath =$ {bkrootpath}/$ {bkdate} log =$ {bkdate }. log # log date = 'date + % Y % m % d % k % M % s' backfile1 =1 {dblist1 }. 0. db2inst1. node).catn0000. $ {date} backfile2 =$ {dblist2 }. 0. db2inst1. node).catn0000. $ {date} # initialize the db2 environment if [-f $ {HOME}/sqllib/db2profile]; then. $ {HOME}/sqllib/db2profilefi # create a backup path if [-d $ {bkrootpath}]; then echo "" else mkdir $ {bkrootpath} fiif [-d $ {bkpath}]; then cd $ {bkpath} echo "backed up today" >>$ {log} else mkdir $ {bkpath} cd $ {bkpath} fidb2stop force # Stop db2 database db2start # restart db2 database, to ensure normal backup, echo "--------------------" >$ {log} echo "$ {bkdate}" >$ {log} echo ">>$ {log} echo" to back up database List ">>$ {log} echo" ${dblist1 }, $ {dblist2} ">$ {log} # connect to the backup database 1db2set db2codepage = 1386db2 connect to $ {dblist1} echo" Start backup $ {dblist1} ">$ {log} echo "backing up ...... ">$ {log} db2 backup db $ {dblist1} to" $ {bkpath} "if [-d" $ {backfile1} "]; then echo "successfully backed up the database $ {dblist1}" >$ {log} else echo "failed to back up the database $ {dblist1}" >$ {log} fidb2stop forcedb2start # connect to the backup database 2db2set db2codepage = 1386 db2 connect to $ {dblist2} echo "Start backup $ {dblist2}" >$ {log} echo "backing up ...... ">$ {log} db2 backup db $ {dblist2} to" $ {bkpath} "if [-d" $ {backfile2} "]; then echo "successfully backed up database $ {dblist2}" >$ {log} else echo "failed to back up database $ {dblist2}" >>> {log} fi

 


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.