免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: —_—!搏
打印 上一主题 下一主题

求助Networker 7.4 + NMS3.0 + Sybase 12.54 无法自动备份,谢谢大家 [复制链接]

论坛徽章:
0
21 [报告]
发表于 2010-05-31 16:07 |只看该作者
#!/bin/sh
#
# $Id: nsrsyb.sh,v 1.13.84.11 2007/05/11 12:08:56 sharmh Exp $ Copyright (c) 2007, EMC Corporation.
#
#
# Copyright (c) 2007, EMC Corporation.
#
# All rights reserved.  This is an UNPUBLISHED work, and
# comprises proprietary and confidential information of EMC.  
# Unauthorized use, disclosure, and distribution are strictly
# prohibited.  Use, duplication, or disclosure of the software
# and documentation by the U.S. Government is subject to
# restrictions set forth in a license agreement between the
# Government and EMC or other written agreement specifying
# the Government's rights to use the software and any applicable
# FAR provisions, such as FAR 52.227-19.
#
# nsrsyb
#
# This script is part of the Networker Module for Sybase.
# Modification of this script should be done with care and only after reading
# the administration manual included with this product.
#
# This script should only be run as part of a scheduled savegroup.
#
# Returns 0 on success; 1 on failure.
#


###########################################################################
# This value MUST be set for scheduled backups to run.
###########################################################################
#
# Variable: SYBASE
# Default value:
# Description: Specifies where the Sybase RDBMS is installed.
# Set this variable to the directory where Sybase ASE
# software is installed. This *must* be set for scheduled backups
# to be able to find the Sybase libraries and executables.
#
SYBASE=/export/home/sybase/ASE-12_5
. $SYBASE/SYBASE.sh
###########################################################################


#
# Configuration variables, modifiable by users.
#
###########################################################################
# The following lines may be edited to change the default settings.  These
# are for advanced tailoring of backups and should be edited carefully.
###########################################################################

#
# Variable: USE_CONSISTENCY_CHECK
# Default value: true
# If set, this puts a consistency check into the PRECMD variable.
# To disable this, set the USE_CONSISTENCY_CHECK value as follows:
# USE_CONSISTENCY_CHECK=
#
# If this is on, it will set the PRECMD to do a consistency check.
# If you need to customize the PRECMD to do other work, unset this
# value and perform any desired consistency checks in your own
# script.
#
USE_CONSISTENCY_CHECK=true

#
# Variable: DBCCOPT
# Default value: none
# If set, these are the options that the nsrsybcc program uses in its
# consistency check.  If not set, the options will be the program defaults
# from the nsrsybcc program.
#
DBCCOPT="-o ckdb"

#
# Variable: PRECMD
# Default value:
# Description: This variable can be used to run a command before nsrsybsv.
#
# If USE_CONSISTENCY_CHECK is set, the PRECMD will be constructed to perform
# a nsrsybcc check on the given saveset.  A PRECMD that you set here will
# not be overwritten by a consistency check, however.
#
PRECMD=

#
# Variable: POSTCMD
# Default value: NONE
# Description: This variable can be used to run a command after nsrsybsv
# has completed.
#
POSTCMD=

#
# Variable: BACKUP_OPT
# Default value: none
# If set, these are the options that will be passed to the nsrsybsv
# program in addition to the ones set from savegrp.  This is useful
# for setting the debug level.
# Passing -N option is not recommended as it will be overwritten by
# what is passed from the savegroup.
#
#BACKUP_OPT="-D 4"
#
BACKUP_OPT="-b sybasefull"

#
# Variable: NSR_DATA_VOLUME_POOL
# Default value: none
# Description: If this variable is set to name a media pool, then database
# backups will be directed to the named media pool.
#
NSR_DATA_VOLUME_POOL=

#
# Variable: NSR_LOG_VOLUME_POOL
# Default value: none
# Description: If this variable is set to name a media pool, then
# transaction log backups will be directed to the named media pool.
#
NSR_LOG_VOLUME_POOL=

#
# Variable: NSR_COMPRESSION
# Default value: FALSE
# Description: This environment variable specifies whether client-side
# compression is performed on the data.
#
NSR_COMPRESSION=FALSE

#
# Variable: NSR_AES_ENCRYPTION
# Default value: FALSE
# Description: This environment variable specifies whether AES encryption
# is used between the client and server.
#
NSR_AES_ENCRYPTION=FALSE

#
# Variable: NSR_ASE_PASSWORD
# Default value: None
# Description: This environment variable specifies the password
# to be used while dumping for ASE 12.5.2 onwards.
#
NSR_ASE_PASSWORD=

#
# Variable: NSR_ASE_VERIFY
# Default value: None
# Description: This environment variable specifies the verify
# clause to be used while issuing dump command for ASE 12.5.4 onwards.
# The valid values can be either "header" or "full". The value
# is case insensitive. The option header will verify only the
# header before dump. The option full will verify both
# header and row structure.
# Note that the verify clause does not work with ASE 15.0.
#
NSR_ASE_VERIFY=

#
# Variable: NSR_DEBUG_FILE
# Default value: /nsr/applogs/xbsa.messages
# Description: This environment variable specifies which file the XBSA
# messages should be written to.
#
NSR_DEBUG_FILE=/nsr/applogs/xbsa.messages

###########################################################################
# Do not edit anything below this line.
###########################################################################

# Set up the PATH environment variable.  This must be configured to include
# the path to the "nsrsybrc", "nsrsybsv", and "nsrsybcc" executables.
PATH=:/bin:/usr/sbin:/opt/networker/bin:/usr/bin:/usr/sbin/nsr

Pid=0                                # process to kill if we are cancelled
nsrsybsv_status=0                # did it work?




#
# Make sure all environment variables are exported
#
export_environment_variables()
{
        if [ "$NSR_COMPRESSION" != "" ]
        then
                export NSR_COMPRESSION
        fi

        if [ "$NSR_AES_ENCRYPTION" != "" ]
        then
                export NSR_AES_ENCRYPTION
        fi

        if [ "$NSR_LOG_VOLUME_POOL" != "" ]
        then
                export NSR_LOG_VOLUME_POOL
        fi

        if [ "$NSR_DATA_VOLUME_POOL" != "" ]
        then
                export NSR_DATA_VOLUME_POOL
        fi

        if [ "$NSR_GROUP" != "" ]
        then
                export NSR_GROUP
        fi

        if [ "$PRECMD" != "" ]
        then
                export PRECMD
        fi

        if [ "$POSTCMD" != "" ]
        then
                export POSTCMD
        fi

        if [ "$SYBASE" != "" ]
        then
                export SYBASE
        fi

        if [ "$PATH" != "" ]
        then
                export PATH
        fi
       
        if [ "$NSR_ASE_PASSWORD" != "" ]
        then
                export NSR_ASE_PASSWORD
        fi

        if [ "$NSR_ASE_VERIFY" != "" ]
        then
                export NSR_ASE_VERIFY
        fi

        if [ "$NSR_DEBUG_FILE" != "" ]
        then
                export NSR_DEBUG_FILE
        fi
}


#
# Handle cancel signals sent by savegrp when user stops the group.
#
handle_signal()
{
        if [ $Pid != 0 ]; then
                kill -2 $Pid
        fi
        exit 1
}


#
# Utility function for adding parameters on to the existing precmd.
# This is used to build up the precmd from the command line arguments.
#
add_arg_to_pre_command()
{
        if [ "$1" != "" ]
        then
                PRECMD=$PRECMD" ""$1"
        fi
}


#
# Process the arguments to find the saveset name.
# this will be used in the PRECMD for the database
# consistency check.  The only things we check for
# are parameters that we'll need to use for the
# nsrsybcc program.
#
# This also builds the actual backup command.  Group
# names are problematic since the quoting doesn't work
# quite right, so we always export the group name.
#
processargs()
{
        DBCC_SAVESET_NAME=
        DBCC_USERNAME=
        DBCC_PASSWORD=
        DBCC_CLIENT=
        DBCC_SERVER=
        DBCC_DEBUG=
        DBCC_QUIET=
        DBCC_VERBOSE=

        # Add the backup options to the backup command.
        BACKUP_COMMAND="nsrsybsv"
        if [ "${BACKUP_OPT}" != "" ];
        then
                BACKUP_COMMAND=$BACKUP_COMMAND" ""$BACKUP_OPT"
        fi


        while test $# -gt 0
        do
                case "$1" in
                -N)        # Get the save set name
                        DBCC_SAVESET_NAME="$2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -g)        # get the group name
                        NSR_GROUP=$2
                        shift
                        shift
                        ;;

                -U)        # get the user name
                        DBCC_USERNAME="$1 $2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -P)        # get the password
                        DBCC_PASSWORD="$1 $2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -c)        # get the client
                        DBCC_CLIENT="$1 $2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -s)        # get the server
                        DBCC_SERVER="$1 $2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -D)        # get the debug level
                        DBCC_DEBUG="$1 $2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -q)        # get the quiet flag
                        DBCC_QUIET="$1"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1"
                        shift
                        ;;

                -v)        # get the verbose flag
                        DBCC_VERBOSE="$1"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1"
                        shift
                        ;;

                *)        # it is some other argument that we will skip
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1"
                        shift
                        ;;
                esac

        done

        #
        # If we don't already have a PRECMD and we are supposed to
        # do a database consistency check, we'll build the PRECMD
        # to be a database consistency check of the save set name
        # supplied. We'll take the default nsrsybcc options.
        # To change the options the consistency check uses, edit the PRECMD line
        # with the desired options.
        #
        if [ "${PRECMD}" = "" ] && [ "${USE_CONSISTENCY_CHECK}" != "" ]
        then
                PRECMD=nsrsybcc

                add_arg_to_pre_command "$DBCCOPT"
                add_arg_to_pre_command "$DBCC_USERNAME"
                add_arg_to_pre_command "$DBCC_PASSWORD"
                add_arg_to_pre_command "$DBCC_CLIENT"
                add_arg_to_pre_command "$DBCC_SERVER"
                add_arg_to_pre_command "$DBCC_DEBUG"
                add_arg_to_pre_command "$DBCC_QUIET"
                add_arg_to_pre_command "$DBCC_VERBOSE"
                add_arg_to_pre_command "$DBCC_SAVESET_NAME"
        fi
}


#
# The main portion of this shell.
#


#
# Make sure we respond to savegrp cancellations.
#
trap handle_signal 2 15


#
# Build the nsrsybsv command
#

#
# Find the saveset name to use for the database consistency check
# and construct the BACKUP_COMMAND to call nsrsybsv.
#
processargs "$@"


#
# Export all necessary environment variables
#
export_environment_variables

#
# Call nsrsybsv to do the backups.
#

# echo ${BACKUP_COMMAND}

${BACKUP_COMMAND} &
Pid=$!
wait $Pid

nsrsybsv_status=$?
if [ $nsrsybsv_status != 0 ] ; then
        echo "nsrsybsv returned status of "$nsrsybsv_status
        echo  $0 "exiting."
        exit 1
fi

exit 0

























谢谢你啦

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
22 [报告]
发表于 2010-05-31 16:07 |只看该作者
兄弟,我试了试您这个办法,还真不行报OCS lib 的PATH不对。是不是我哪儿里没设置正确呢?

43 ...
—_—!搏 发表于 2010-05-31 11:08



还是变量的问题啊

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
23 [报告]
发表于 2010-05-31 16:18 |只看该作者
还有让你注释掉的也没注释掉

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
24 [报告]
发表于 2010-05-31 16:19 |只看该作者
把sybase的env输出和root的env输出比较一下

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
25 [报告]
发表于 2010-05-31 16:27 |只看该作者
还有就是可以把nsrsyb加上-x选项,看看那里报错
就是sh -x nsrsyb xxxxx    xxxxx 是备份选项
或者脚本第一行改成#!/bin/sh -x
这样可以看到脚本执行的每一步

论坛徽章:
0
26 [报告]
发表于 2010-05-31 17:13 |只看该作者
回复 22# yddll


    但是我没有OCS的lib啊。

论坛徽章:
0
27 [报告]
发表于 2010-05-31 17:21 |只看该作者
SYBASE=/export/home/sybase/ASE-12_5
. $SYBASE/SYBASE.sh
这个参数一定要设对

另外这两个参数必设
NSR_DATA_VOLUME_POOL=
NSR_LOG_VOLUME_POOL=

论坛徽章:
0
28 [报告]
发表于 2010-05-31 17:27 |只看该作者
好的,多谢你们大伙

nsrsyb的这个脚本我怎么控制用solaris系统用户sybase执行,而不是用solaris系统用户root执行呢


我现在就是sybase用户下执行这个脚本,一点问题没有。
但在console服务器图形化界面,就不行。root用户下执行这个脚本,也不行。报错是一样一样的

论坛徽章:
0
29 [报告]
发表于 2010-05-31 21:48 |只看该作者
好的,多谢你们大伙

在console服务器图形化界面,就不行。root用户下执行这个脚本,也不行。报错是一样一样的
—_—!搏 发表于 2010-05-31 17:27



    yddll说的对,关键是root和sybase的env。

查一下SYBASE.SH,看看少哪些些变量补进去,可以在sybase的profile里找。比如SYBASE_OCS,LIBPATH等,都是必须的~~

把这个/nsr/applogs/xbsa.messages贴一下看看能找到有价值的信息么~

如果实在搞不定的话,也可以考虑用savepnpc的方法,自己写脚本,指定su 到sybase执行nsrsybsv+savegrp的办法~

论坛徽章:
0
30 [报告]
发表于 2010-06-01 22:26 |只看该作者
十分感谢你们!

现在我感觉问题不是出在env或者是SYBASE.sh。

按大家所说的我都做过了。

感觉是nsrsyb脚本调用nsrsybsv这个备份命令,这个备份命令在指导书上说不能在root用户下运行,所以必须在sybase用户运行。

我就想在nsrsyb脚本里加上su - sybase,但是不懂shell语句,导致备份命令和su - sybase 用户不能结合使用啊

# Set up the PATH environment variable.  This must be configured to include
# the path to the "nsrsybrc", "nsrsybsv", and "nsrsybcc" executables.
PATH=:/bin:/usr/sbin:/opt/networker/bin:/usr/bin:/usr/sbin/nsr

Pid=0                                # process to kill if we are cancelled
nsrsybsv_status=0                # did it work?




#
# Make sure all environment variables are exported
#
export_environment_variables()
{
        if [ "$NSR_COMPRESSION" != "" ]
        then
                export NSR_COMPRESSION
        fi

        if [ "$NSR_AES_ENCRYPTION" != "" ]
        then
                export NSR_AES_ENCRYPTION
        fi

        if [ "$NSR_LOG_VOLUME_POOL" != "" ]
        then
                export NSR_LOG_VOLUME_POOL
        fi

        if [ "$NSR_DATA_VOLUME_POOL" != "" ]
        then
                export NSR_DATA_VOLUME_POOL
        fi

        if [ "$NSR_GROUP" != "" ]
        then
                export NSR_GROUP
        fi

        if [ "$PRECMD" != "" ]
        then
                export PRECMD
        fi

        if [ "$POSTCMD" != "" ]
        then
                export POSTCMD
        fi

        if [ "$SYBASE" != "" ]
        then
                export SYBASE
        fi

        if [ "$PATH" != "" ]
        then
                export PATH
        fi
       
        if [ "$NSR_ASE_PASSWORD" != "" ]
        then
                export NSR_ASE_PASSWORD
        fi

        if [ "$NSR_ASE_VERIFY" != "" ]
        then
                export NSR_ASE_VERIFY
        fi

        if [ "$NSR_DEBUG_FILE" != "" ]
        then
                export NSR_DEBUG_FILE
        fi
}


#
# Handle cancel signals sent by savegrp when user stops the group.
#
handle_signal()
{
        if [ $Pid != 0 ]; then
                kill -2 $Pid
        fi
        exit 1
}


#
# Utility function for adding parameters on to the existing precmd.
# This is used to build up the precmd from the command line arguments.
#
add_arg_to_pre_command()
{
        if [ "$1" != "" ]
        then
                PRECMD=$PRECMD" ""$1"
        fi
}


#
# Process the arguments to find the saveset name.
# this will be used in the PRECMD for the database
# consistency check.  The only things we check for
# are parameters that we'll need to use for the
# nsrsybcc program.
#
# This also builds the actual backup command.  Group
# names are problematic since the quoting doesn't work
# quite right, so we always export the group name.
#
processargs()
{
        DBCC_SAVESET_NAME=
        DBCC_USERNAME=
        DBCC_PASSWORD=
        DBCC_CLIENT=
        DBCC_SERVER=
        DBCC_DEBUG=
        DBCC_QUIET=
        DBCC_VERBOSE=

        # Add the backup options to the backup command.
        BACKUP_COMMAND="nsrsybsv"
        if [ "${BACKUP_OPT}" != "" ];
        then
                BACKUP_COMMAND=$BACKUP_COMMAND" ""$BACKUP_OPT"
        fi


        while test $# -gt 0
        do
                case "$1" in
                -N)        # Get the save set name
                        DBCC_SAVESET_NAME="$2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -g)        # get the group name
                        NSR_GROUP=$2
                        shift
                        shift
                        ;;

                -U)        # get the user name
                        DBCC_USERNAME="$1 $2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -P)        # get the password
                        DBCC_PASSWORD="$1 $2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -c)        # get the client
                        DBCC_CLIENT="$1 $2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -s)        # get the server
                        DBCC_SERVER="$1 $2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -D)        # get the debug level
                        DBCC_DEBUG="$1 $2"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1 $2"
                        shift
                        shift
                        ;;

                -q)        # get the quiet flag
                        DBCC_QUIET="$1"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1"
                        shift
                        ;;

                -v)        # get the verbose flag
                        DBCC_VERBOSE="$1"
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1"
                        shift
                        ;;

                *)        # it is some other argument that we will skip
                        BACKUP_COMMAND=$BACKUP_COMMAND" ""$1"
                        shift
                        ;;
                esac

        done

        #
        # If we don't already have a PRECMD and we are supposed to
        # do a database consistency check, we'll build the PRECMD
        # to be a database consistency check of the save set name
        # supplied. We'll take the default nsrsybcc options.
        # To change the options the consistency check uses, edit the PRECMD line
        # with the desired options.
        #
        if [ "${PRECMD}" = "" ] && [ "${USE_CONSISTENCY_CHECK}" != "" ]
        then
                PRECMD=nsrsybcc

                add_arg_to_pre_command "$DBCCOPT"
                add_arg_to_pre_command "$DBCC_USERNAME"
                add_arg_to_pre_command "$DBCC_PASSWORD"
                add_arg_to_pre_command "$DBCC_CLIENT"
                add_arg_to_pre_command "$DBCC_SERVER"
                add_arg_to_pre_command "$DBCC_DEBUG"
                add_arg_to_pre_command "$DBCC_QUIET"
                add_arg_to_pre_command "$DBCC_VERBOSE"
                add_arg_to_pre_command "$DBCC_SAVESET_NAME"
        fi
}


#
# The main portion of this shell.
#


#
# Make sure we respond to savegrp cancellations.
#
trap handle_signal 2 15


#
# Build the nsrsybsv command
#

#
# Find the saveset name to use for the database consistency check
# and construct the BACKUP_COMMAND to call nsrsybsv.
#
processargs "$@"


#
# Export all necessary environment variables
#
export_environment_variables

#
# Call nsrsybsv to do the backups.
#

# echo ${BACKUP_COMMAND}

${BACKUP_COMMAND} &
Pid=$!
wait $Pid

nsrsybsv_status=$?
if [ $nsrsybsv_status != 0 ] ; then
        echo "nsrsybsv returned status of "$nsrsybsv_status
        echo  $0 "exiting."
        exit 1
fi

exit 0


请高手帮忙看下,如何使su - sybase 与此环境结合使用呢。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP