NBU For Sybase scrips

#!/bin/sh

# sybase_mydb_backup $Revision: 1.3 $

#bcpyrght

#***************************************************************************

#* $VRTScprght: Copyright 1993 - 2007 Symantec Corporation, All Rights Reserved $ *

#***************************************************************************

#ecpyrght

 

#***************************************************************************

# Replace /usr/sybase12 below with the actual Sybase home directory 

#***************************************************************************

SYBASE=/export/home/sybase-prog

 

#***************************************************************************

# Replace SYBASE12 below with the actual name of the SQL Server

#***************************************************************************

SYBSERVER=TFHDB

 

#***************************************************************************

# Replace SYB_DB below with the actual name of your Sybase database

#***************************************************************************

DATABASE_NAME=test

 

#***************************************************************************

# Replace syb_files below with your actual name of the NetBackup 

# server Policy to be used to backup the directory with Sybase script files

#***************************************************************************

SYB_FILES_POLICY=syb_files 

 

#***************************************************************************

# Replace /usr/sybase12/scripts below with your actual path of the Sybase files 

#***************************************************************************

SYB_FILES_DIR=/usr/sybase12/scripts

 

#***************************************************************************

# Determine the SYBASE_ASE and SYBASE_OCS env variables for Sybase 12.x

#***************************************************************************

OCS_QUAL=

if [ -f "${SYBASE}"/SYBASE.csh ] ; then

        SYBASE_ASE=`grep "setenv SYBASE_ASE" "${SYBASE}"/SYBASE.csh | cut -f3 -d" " | sort -u | head -1`

        SYBASE_OCS=`grep "setenv SYBASE_OCS" "${SYBASE}"/SYBASE.csh | cut -f3 -d" " | sort -u | head -1`

        export SYBASE_ASE

        export SYBASE_OCS

        OCS_QUAL=/$SYBASE_OCS

elif [ -f "${SYBASE}"/SYBASE.sh ] ; then

        SYBASE_ASE=`grep "SYBASE_ASE=" "${SYBASE}"/SYBASE.sh | cut -f2 -d"=" | sort -u | head -1`

        SYBASE_OCS=`grep "SYBASE_OCS=" "${SYBASE}"/SYBASE.sh | cut -f2 -d"=" | sort -u | head -1`

        export SYBASE_ASE

        export SYBASE_OCS

        OCS_QUAL=/$SYBASE_OCS

fi

 

echo "Started `date`"

SYBASE=$SYBASE; export SYBASE

# These environment variables are set by NetBackup 

echo "SYBACKUP_SERVER = $SYBACKUP_SERVER"

echo "SYBACKUP_POLICY = $SYBACKUP_POLICY"

echo "SYBACKUP_SCHED = $SYBACKUP_SCHED"

echo "SYBACKUP_CLIENT = $SYBACKUP_CLIENT"

echo "SYBACKUP_SCHEDULED = $SYBACKUP_SCHEDULED"

echo "SYBACKUP_USER_INITIATED = $SYBACKUP_USER_INITIATED"

 

RETURN_STATUS=0

 

#***************************************************************************

# Replace "database_dump" below with your actual NetBackup schedule name

# which is used for a full backup of the Sybase database.

#***************************************************************************

if [ "${SYBACKUP_SCHED}" = "NBU_Sybase_backup" ]

then

############# NetBackup has started a "database_dump" backup ##############

DUMP_TYPE=DATABASE

 

else

############# NetBackup has started a "transaction log" backup ##############

DUMP_TYPE=TRANSACTION

fi

 

#***************************************************************************

# Replace "Default-Application-Backup" below with your actual NetBackup 

# Application Backup type schedule name for the Sybase database. 

#***************************************************************************

echo dump $DUMP_TYPE $DATABASE_NAME to /"sybackup::-SERV $SYBACKUP_SERVER -CLIENT $SYBACKUP_CLIENT -POL $SYBACKUP_POLICY -SCHED Default-Application-Backup/" > ./syb_${DATABASE_NAME}_dump

 

#**************************************************************************

# Remove the '#' from the beginning of the line below if you are going to

# use multiple stripes for the backup. Repeat this line for each stripe.

# Replace "Default-Application-Backup" below with your actual NetBackup

# Application Backup type schedule name for the Sybase database.

# **************************************************************************

# echo stripe on /"sybackup::-SERV $SYBACKUP_SERVER -CLIENT $SYBACKUP_CLIENT -POL $SYBACKUP_POLICY -SCHED Default-Application-Backup/" >> ./syb_${DATABASE_NAME}_dump 

 

echo go >> ./syb_${DATABASE_NAME}_dump

 

#***************************************************************************

# Log the isql command. This line may appear in NetBackup log files.

# Do NOT replace "xxxxxxxx" with a user id or password.

#***************************************************************************

echo "$SYBASE$OCS_QUAL/bin/isql -Uxxxxxxxx -Pxxxxxxxx -I$SYBASE/interfaces -S$SYBSERVER < ./syb_${DATABASE_NAME}_dump"

 

#***************************************************************************

# Replace "sa" with your Sybase server Administrator's login name.

# Replace "manager" with your Sybase server Administrator's password.

#***************************************************************************

$SYBASE$OCS_QUAL/bin/isql -Uzyk -Pz19680923 -I$SYBASE/interfaces -S$SYBSERVER < ./syb_${DATABASE_NAME}_dump

RETURN_STATUS=$?

 

if [ "${DUMP_TYPE}" = "DATABASE" ]

then

# Initiate a backup of any file related to the Sybase database, such as script files.

 

echo "bpbackup -c $SYB_FILES_POLICY $SYB_FILES_DIR"

/usr/openv/netbackup/bin/bpbackup -c $SYB_FILES_POLICY $SYB_FILES_DIR

BPBACKUP_STATUS=$?

 

if [ "$BPBACKUP_STATUS" -ne 0 ]

then

echo ""

echo "bpbackup of $SYB_FILES_DIR returned $BPBACKUP_STATUS"

fi

fi

 

 

echo "Finished `date`"

 

echo "exit $RETURN_STATUS"

echo ""

 

exit $RETURN_STATUS

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值