- 论坛徽章:
- 0
|
$ more ctrl.sh
#!/bin/sh
# -----------------------------------------------------------------
# Backup script generated on 12/04/03 17:11:32
# Shell Script name: HotDBFull.sh
#
# VERITAS NetBackup for oracle on UNIX
$VRTScprght: Copyright 1993 - 2003 VERITAS Software Corporation, All Rights Reserved $ #
# -----------------------------------------------------------------
ORACLE_HOME=/opt/oracle/db01/app/oracle/product/8.1.7
ORACLE_SID=inms
RMAN_LOG_FILE=/opt/oracle/rman/rman.log
TARGET_CONNECT_STR=system/manager
CATALOG_CONNECT_STR=rman/rman@rman
RUN_AS_USER=root
RMAN=$ORACLE_HOME/bin/rman
CUSER=`id | cut -d"(" -f2 | cut -d ")" -f1`
# -----------------------------------------------------------------
# If this script is executed from a NetBackup schedule, NetBackup
# sets an NB_ORA environment variable based on the schedule type.
# The NB_ORA variable is then used to dynamically set BACKUP_TYPE.
# For example, when:
# schedule type is BACKUP_TYPE is
# ---------------- --------------
# Automatic Full INCREMENTAL LEVEL=0
# Automatic Differential Incremental INCREMENTAL LEVEL=1
# Automatic Cumulative Incremental INCREMENTAL LEVEL=1 CUMULATIVE
# For user initiated backups, BACKUP_TYPE defaults to incremental
# level 0 (full). To change the default for a user initiated
# backup to incremental or incremental cumulative, uncomment
# one of the following two lines.
# BACKUP_TYPE="INCREMENTAL LEVEL=1"
# BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"
# Note that we use incremental level 0 to specify full backups.
# That is because, although they are identical in content, only
# the incremental level 0 backup can have incremental backups of
# level > 0 applied to it.
# -----------------------------------------------------------------
#if [ "$NB_ORA_FULL" = "1" ]
#then
# BACKUP_TYPE="INCREMENTAL LEVEL=0"
#elif [ "$NB_ORA_INCR" = "1" ]
#then
# BACKUP_TYPE="INCREMENTAL LEVEL=1"
#elif [ "$NB_ORA_CINC" = "1" ]
#then
# BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"
#elif [ "$BACKUP_TYPE" = "" ]
#then
# BACKUP_TYPE="INCREMENTAL LEVEL=0"
#fi
# -----------------------------------------------------------------
# Initialize the log file.
# -----------------------------------------------------------------
#> $RMAN_LOG_FILE
chmod 666 $RMAN_LOG_FILE
# -----------------------------------------------------------------
# Log the start of this script.
# -----------------------------------------------------------------
echo Script $0 >> $RMAN_LOG_FILE
echo ==== started on `date` ==== >> $RMAN_LOG_FILE
echo >> $RMAN_LOG_FILE
# -----------------------------------------------------------------
# rman commands for database ORCL.
# -----------------------------------------------------------------
CMD="
ORACLE_HOME=/opt/oracle/db01/app/oracle/product/8.1.7
export ORACLE_HOME
ORACLE_SID=inms
export ORACLE_SID
$RMAN target $TARGET_CONNECT_STR rcvcat $CATALOG_CONNECT_STR msglog $RMAN_LOG_FILE append <<EOF
run { execute script 'hot_database_backup_ctrl';}
EOF
"
if [ "$CUSER" = "root" ]
then
su - $RUN_AS_USER -c "$CMD" >> $RMAN_LOG_FILE
RSTAT=$?
else
sh -c "$CMD" >> $RMAN_LOG_FILE
RSTAT=$?
fi
if [ "$RSTAT" = "0" ]
then
LOGMSG="ended successfully"
else
LOGMSG="ended in error"
fi
# -----------------------------------------------------------------
# Log the completion of this script.
# -----------------------------------------------------------------
echo >> $RMAN_LOG_FILE
echo Script $0 >> $RMAN_LOG_FILE
echo ==== $LOGMSG on `date` ==== >> $RMAN_LOG_FILE
exit $RSTAT
RMAN> print script hot_database_backup_ctrl;
RMAN-03027: printing stored script: hot_database_backup_ctrl
{
allocate channel c1 type disk;
backup current controlfile format '/opt/oracle/hot_backup/ctrl%t%s.%p';
}
$ more rman.log
Sun Microsystems Inc. SunOS 5.8 Generic Patch October 2001
You have new mail.
Recovery Manager: Release 8.1.7.3.0 - Production
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database: ORA-01031: insufficient privileges
Script ./ctrl.sh
==== ended in error on Tue Nov 21 12:15:46 CST 2006 ====
在rman下运行以下命令没问题,请各位大虾帮忙分析下为什么放在脚本里会出现这种错误呢?
RMAN>run { execute script 'hot_database_backup_ctrl';} |
|