db2 online backup shell

href="file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_filelist.xml" rel="File-List" />

#!/bin/sh

usage()

{

    echo "usage: $0 <DatabaseName>"

    exit 1;

}

 

log_message()

{

    message=$1

    timestamp=`date "+%m/%d/%Y %H:%M:%S"`

    echo "$timestamp $message" >> $LOG

}

 

# Database name is the first argument.

if [ $# -eq 0 ]

then

    usage

fi

 

# Set DB2 environment

. $HOME/sqllib/db2profile

 

DBNAME=$1

BACKUPDIR=/home/db2inst1/db2backup

LOG=/home/db2inst1/db2backup/db2backup.log

 

log_message "*********************************************************************************************************";

log_message "********************************Begin********************************************************************";

log_message "*********************************************************************************************************";

# Make sure there are no active applications

 

NUM=`db2 get db cfg for $DBNAME | grep '(LOGRETAIN) = RECOVERY' | wc -l`

if [ $NUM -ne "1" ]

then

   log_message "The value of LOGRETAIN is 'OFF'. Terminate 30 seconds for changing it's value to 'RECOVERY'"

   db2 update db cfg for $DBNAME using LOGRETAIN ON   >> $LOG 2>&1

   sleep 30

fi

 

NUM=`db2 get db cfg for $DBNAME | grep 'TRACKMOD = ON' | wc -l`

 

if [ $NUM -ne "1" ]

then

            log_message "The value of TRACKMOD is 'OFF'. Terminate 30 seconds for changing it's value to 'ON'"

            db2 update db cfg for $DBNAME using TRACKMOD ON

            sleep 30

fi

 

# Connect to database

log_message "Connecting to database $DBNAME"

db2 connect to $DBNAME >> $LOG 2>&1

 

# Take Backup

log_message "Backing up database to $LOG (online incremental)....This will take a while";

db2 backup database $DBNAME online incremental to $BACKUPDIR compress include logs without prompting >> $LOG 2>&1

 

 

log_message "*********************************************************************************************************";

log_message "********************************End**********************************************************************";

log_message "*********************************************************************************************************";

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值