yihe_zang 发表于 2012-10-11 16:59

NBU7备份Oracle for Windows的两种思路的区别

请教各位大大,现在很少看到NBU7备份win平台Oracle11g的实战了;

现在有两种备份思路:一种是在客户端上按照向导来配置tpl备份模版,然后在服务端来新建策略并加载这个模版来实现备份;

另一种是直接修改NBU提供的rman脚本模版(比如hot_database_backup.cmd),然后通过备份这个cmd脚本来实现Oracle的备份;

不知道这两种备份方式有什么不同,我用了这两种思路都没有备份成功!

第一种报错如下:
2012/10/11 16:43:43 - Info bphdb(pid=3864) DBNAME=ORCL DBHOME=d:\app\administrator\product\11.2.0\dbhome_1 DBNETNAME=orcl DBTEMPLATENAME=oracle.tpl         
2012/10/11 16:44:46 - Error bpbrm(pid=4504) from client orcl: ERR - failed executing command <"C:\Veritas\NetBackup\bin\bpdbsbora.exe" -backup -rw -t "oracle.tpl" -jobid 19>
2012/10/11 16:44:46 - Error bpbrm(pid=4504) from client orcl: ERR - exit status: <1>   
2012/10/11 16:44:46 - Error bpbrm(pid=4504) from client orcl: ERR - bphdb exit status = 29: failed trying to exec a command
2012/10/11 16:44:47 - end writing
failed trying to exec a command(29)

第二种策略执行成功,但是没有备份数据:2012/10/11 15:17:51 - Info nbjm(pid=3116) starting backup job (jobid=17) for client orcl, policy oracle-rman, schedule Full
2012/10/11 15:17:51 - Info nbjm(pid=3116) requesting MEDIA_SERVER_WITH_ATTRIBUTES resources from RB for backup job (jobid=17, request id:{CC359310-248F-4960-A203-C9174BC909D4})
2012/10/11 15:17:51 - requesting resource be2012-disk
2012/10/11 15:17:51 - requesting resource be2012.NBU_CLIENT.MAXJOBS.orcl
2012/10/11 15:17:51 - requesting resource be2012.NBU_POLICY.MAXJOBS.oracle-rman
2012/10/11 15:17:51 - granted resource be2012.NBU_CLIENT.MAXJOBS.orcl
2012/10/11 15:17:51 - granted resource be2012.NBU_POLICY.MAXJOBS.oracle-rman
2012/10/11 15:17:51 - granted resource be2012-disk
2012/10/11 15:17:51 - estimated 0 Kbytes needed
2012/10/11 15:17:51 - Info nbjm(pid=3116) started backup (backupid=orcl_1349939871) job for client orcl, policy oracle-rman, schedule Full on storage unit be2012-disk
2012/10/11 15:17:51 - started process bpbrm (5052)
2012/10/11 15:17:52 - Info bpbrm(pid=5052) orcl is the host to backup data from   
2012/10/11 15:17:52 - Info bpbrm(pid=5052) reading file list from client      
2012/10/11 15:17:52 - connecting
2012/10/11 15:17:55 - Info bpbrm(pid=5052) starting bphdb on client         
2012/10/11 15:17:55 - Info bphdb(pid=3420) Backup started         
2012/10/11 15:17:55 - connected; connect time: 00:00:03
2012/10/11 15:17:57 - Info bpbrm(pid=5052) validating image for client orcl      
2012/10/11 15:17:59 - end writing
the requested operation was successfully completed(0)还请高手指教啊!

无牙 发表于 2012-10-11 18:30

两个方法没什太大的区别。 应该是配置上的问导致备份失败。

第二种方法不是备份那个脚本。是调用那个脚本。

yihe_zang 发表于 2012-10-12 11:30

回复 2# 无牙


   无牙前辈,NBU提供的rman脚本模版要修改那些地方呢?
@REM $Header: hot_database_backup.cmd,v 1.4 2010/08/04 17:55:57 $

@REM bcpyrght
@REM ***************************************************************************
@REM * $VRTScprght: Copyright 1993 - 2012 Symantec Corporation, All Rights Reserved $ *
@REM ***************************************************************************
@REM ecpyrght
@REM
@REM ---------------------------------------------------------------------------
@REM                        hot_database_backup.cmd
@REM ---------------------------------------------------------------------------
@REM This script uses Recovery Manager to take a hot (inconsistent) database
@REM backup. A hot backup is inconsistent because portions of the database are
@REM being modified and written to the disk while the backup is progressing.
@REM You must run your database in ARCHIVELOG mode to make hot backups.
@REM ---------------------------------------------------------------------------

@setlocal ENABLEEXTENSIONS

@REM ---------------------------------------------------------------------------
@REM No need to echo the commands.
@REM ---------------------------------------------------------------------------

@echo off

@REM ---------------------------------------------------------------------------
@REM Put output in the same filename, different extension.
@REM ---------------------------------------------------------------------------

@set RMAN_LOG_FILE="%~dpn0.out"

@REM ---------------------------------------------------------------------------
@REM You may want to delete the output file so that backup information does
@REM not accumulate.If not, delete the following command.
@REM ---------------------------------------------------------------------------

@if exist %RMAN_LOG_FILE% del %RMAN_LOG_FILE%

@REM ---------------------------------------------------------------------------
@REM Replace H:\oracle\ora102, below, with the Oracle home path.
@REM ---------------------------------------------------------------------------

@set ORACLE_HOME=D:\app\Administrator\product\11.2.0\dbhome_1

@REM ---------------------------------------------------------------------------
@REM Replace ora102, below, with the Oracle SID.
@REM ---------------------------------------------------------------------------

@set ORACLE_SID=orcl

@REM ---------------------------------------------------------------------------
@REM Replace sys/manager, below, with the target connect string.
@REM ---------------------------------------------------------------------------

@set TARGET_CONNECT_STR=sys/redhat123,

@REM ---------------------------------------------------------------------------
@REM Set the Oracle Recovery Manager.
@REM ---------------------------------------------------------------------------

@set RMAN=%ORACLE_HOME%\bin\rman.exe

@REM ---------------------------------------------------------------------------
@REM Log the start of this script.
@REM ---------------------------------------------------------------------------

@for /F "tokens=1*" %%p in ('date /T') do @set DATE=%%p %%q
@for /F %%p in ('time /T') do @set DATE=%DATE% %%p

@echo ==== started on %DATE% ==== >> %RMAN_LOG_FILE%
@echo Script name: %0 >> %RMAN_LOG_FILE%

@REM ---------------------------------------------------------------------------
@REM Several RMAN commands use time parameters that require NLS_LANG and
@REM NLS_DATE_FORMAT to be set. This example uses the standard date format.
@REM Replace below with the desired language values.
@REM ---------------------------------------------------------------------------

@set NLS_LANG=american
@set NLS_DATE_FORMAT=YYYY-MM-DD:hh24:mi:ss

@REM ---------------------------------------------------------------------------
@REM Print out environment variables set in this script.
@REM ---------------------------------------------------------------------------

@echo #                                       >> %RMAN_LOG_FILE%
@echo   RMAN:%RMAN%                     >> %RMAN_LOG_FILE%
@echo   NLS_LANG:%NLS_LANG%               >> %RMAN_LOG_FILE%
@echo   ORACLE_HOME:%ORACLE_HOME%         >> %RMAN_LOG_FILE%
@echo   ORACLE_SID:%ORACLE_SID%         >> %RMAN_LOG_FILE%
@echo   NLS_DATE_FORMAT:%NLS_DATE_FORMAT% >> %RMAN_LOG_FILE%
@echo   RMAN_LOG_FILE:%RMAN_LOG_FILE%   >> %RMAN_LOG_FILE%

@REM ---------------------------------------------------------------------------
@REM Print out environment variables set in bphdb.
@REM ---------------------------------------------------------------------------

@echo   NB_ORA_SERV:%NB_ORA_SERV%                     >> %RMAN_LOG_FILE%
@echo   NB_ORA_FULL:%NB_ORA_FULL%                     >> %RMAN_LOG_FILE%
@echo   NB_ORA_INCR:%NB_ORA_INCR%                     >> %RMAN_LOG_FILE%
@echo   NB_ORA_CINC:%NB_ORA_CINC%                     >> %RMAN_LOG_FILE%

@REM ---------------------------------------------------------------------------
@REM We assume that the database is properly opened. If desired, this would
@REM be the place to verify that.
@REM ---------------------------------------------------------------------------

@REM ---------------------------------------------------------------------------
@REM If this script is executed from a NetBackup schedule, NetBackup
@REM sets an NB_ORA environment variable based on the schedule type.
@REM For example, when:
@REM   schedule type is                BACKUP_TYPE is
@REM   ----------------                --------------
@REM Automatic Full                      INCREMENTAL LEVEL=0
@REM Automatic Differential IncrementalINCREMENTAL LEVEL=1
@REM Automatic Cumulative Incremental    INCREMENTAL LEVEL=1 CUMULATIVE
@REM
@REM For user initiated backups, BACKUP_TYPE defaults to incremental
@REM level 0 (Full).To change the default for a user initiated
@REM backup to incremental or incrementatl cumulative, uncomment
@REM one of the following two lines.
@REM @set BACKUP_TYPE="INCREMENTAL LEVEL=1"
@REM @set BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"
@REM
@REM Note that we use incremental level 0 to specify full backups.
@REM That is because, although they are identical in content, only
@REM the incremental level 0 backup can have incremental backups of
@REM level > 0 applied to it.
@REM ---------------------------------------------------------------------------

@REM ---------------------------------------------------------------------------
@REM What kind of backup will we perform.
@REM ---------------------------------------------------------------------------

@if "%NB_ORA_FULL%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=0
@if "%NB_ORA_INCR%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=1
@if "%NB_ORA_CINC%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=1 CUMULATIVE
@if NOT DEFINED BACKUP_TYPE @set BACKUP_TYPE=INCREMENTAL Level=0

@REM ---------------------------------------------------------------------------
@REM Call Recovery Manager to initiate the backup. This example does not use a
@REM Recovery Catalog. If you choose to use one, remove the option, nocatalog,
@REM from the rman command line below and add a
@REM 'catalog <userid>/<passwd>@<net service name>' statement.
@REM
@REMNOTE WHEN USING NET SERVICE NAME: When connecting to a database
@REMusing a net service name, you must use a send command or a parms operand to
@REMspecify environment variables.In other words, when accessing a database
@REMthrough a listener, the environment variables set at the system level are not
@REMvisible when RMAN is running.For more information on the environment
@REMvariables, please refer to the NetBackup for Oracle Admin. Guide.
@REM
@REM If you are getting an error that the input line is too long, you will need
@REM to put the RMAN run block in a separate file.Then use the "cmdfile"
@REM option of RMAN.For more information on the "cmdfile" options please
@REM refer to the RMAN documentation.
@REM ---------------------------------------------------------------------------

@(
echo RUN {
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
echo BACKUP
echo       %BACKUP_TYPE%
echo       FORMAT 'bk_u%%u_s%%s_p%%p_t%%t'
echo       DATABASE;
echo sql 'alter system archive log current';
echo RELEASE CHANNEL ch00;
echo RELEASE CHANNEL ch01;
echo # Backup all archive logs
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo BACKUP
echo       FILESPERSET 20
echo       FORMAT 'arch-s%%s-p%%p-t%%t'
echo       ARCHIVELOG ALL;
echo RELEASE CHANNEL ch00;
@REM ----------------------------------------------------------------------------
@REM Note: During the process of backing up the database, RMAN also backs up the
@REM control file.This version of the control file does not contain the
@REM information about the current backup because "nocatalog" has been specified.
@REM To include the information about the current backup, the control file should
@REM be backed up as the last step of the RMAN section.This step would not be
@REM necessary if we were using a recovery catalog or auto control file backups.
@REM ----------------------------------------------------------------------------
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo BACKUP
@REM recommended format
echo       FORMAT 'cntrl_%s_%p_%t'
echo       CURRENT CONTROLFILE;
echo RELEASE CHANNEL ch00;
echo }
) | %RMAN% target %TARGET_CONNECT_STR% nocatalog msglog '%RMAN_LOG_FILE%' append

@set ERRLEVEL=%ERRORLEVEL%

@REM ---------------------------------------------------------------------------
@REM NetBackup (bphdb) stores the name of a file in an environment variable,
@REM called STATUS_FILE. This file is used by an automatic schedule to
@REM communicate status information with NetBackup's job monitor. It is up to
@REM the script to write a 0 (passed) or 1 (failure) to the status file.
@REM ---------------------------------------------------------------------------

@if %ERRLEVEL% NEQ 0 @goto err

@set LOGMSG=ended successfully
@if "%STATUS_FILE%" EQU "" goto end
@echo 0 > "%STATUS_FILE%"
@goto end

:err
@set LOGMSG=ended in error
@if "%STATUS_FILE%" EQU "" @goto end
@echo 1 > "%STATUS_FILE%"

:end

@REM ---------------------------------------------------------------------------
@REM Log the completion of this script.
@REM ---------------------------------------------------------------------------

@for /F "tokens=1*" %%p in ('date /T') do @set DATE=%%p %%q
@for /F %%p in ('time /T') do @set DATE=%DATE% %%p

@echo #>> %RMAN_LOG_FILE%
@echo %==== %LOGMSG% on %DATE% ==== >> %RMAN_LOG_FILE%
@endlocal
@REM End of Main Program -----------------------------------------------------

liu3231 发表于 2012-10-12 12:13

@set ORACLE_SID=orcl

@set TARGET_CONNECT_STR=sys/redhat123

主要这几个连接数据库的参数,其他的自己按照环境改,英文应该看得懂吧。属性oracle rman备份的就不难

回复 3# yihe_zang


   

yihe_zang 发表于 2012-10-12 13:23

回复 4# liu3231


    贴出来的这个脚本就是修改过的了,备份过程一闪而过,提示成功,可是没有备到数据;

输出文件如下,感觉rman脚本都没开始运行就结束了!==== started on 2012/10/11 周四18:01 ====
Script name: "D:\app\hot_database_backup.cmd"
#                                       
RMAN:D:\app\Administrator\product\11.2.0\dbhome_1\bin\rman.exe                     
NLS_LANG:american               
ORACLE_HOME:D:\app\Administrator\product\11.2.0\dbhome_1         
ORACLE_SID:orcl         
NLS_DATE_FORMAT:YYYY-MM-DD:hh24:mi:ss
RMAN_LOG_FILE:"D:\app\hot_database_backup.out"   
NB_ORA_SERV:be2012                     
NB_ORA_FULL:0                     
NB_ORA_INCR:1                     
NB_ORA_CINC:0                     

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Oct 11 18:01:02 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.All rights reserved.

connected to target database: ORCL (DBID=1324015989)
using target database control file instead of recovery catalog

RMAN>

Recovery Manager complete.
#   

huanglao2002 发表于 2012-10-12 20:58

@REM ----------------------------------------------------------------------------
@REM Note: During the process of backing up the database, RMAN also backs up the
@REM control file.This version of the control file does not contain the
@REM information about the current backup because "nocatalog" has been specified.
@REM To include the information about the current backup, the control file should
@REM be backed up as the last step of the RMAN section.This step would not be
@REM necessary if we were using a recovery catalog or auto control file backups.
@REM ----------------------------------------------------------------------------
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo BACKUP
@REM recommended format

把带@REM 开头的行删除。
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo BACKUP
以上两行需要保留。

myguangzhou 发表于 2012-10-13 00:09

备份一闪而过的问题,我之前就碰到过了,换成6.X的脚本就可以
至于楼上的方法,是否可行?实践过么

QaSanil 发表于 2012-10-13 14:46

回复 3# yihe_zang


常规来说,修改下面三段 ,根据客户具体环境。
@set ORACLE_HOME=D:\app\Administrator\product\11.2.0\dbhome_1

@set ORACLE_SID=orcl

@set TARGET_CONNECT_STR=sys/redhat123,

策略被分类型要选择oracle
还有就是你的nbu7点几的版本?
默认的oracle for windows脚本还有点小bug,可以尝试6.5的
个人认为,欢迎拍砖,楼下补充。

yihe_zang 发表于 2012-10-14 16:30

本帖最后由 yihe_zang 于 2012-10-14 17:25 编辑

回复 8# QaSanil


    我这里的是NBU 7.5,归档模式已开!

单独调用rman脚本也无法备份成功,环境是Oracle 11gr2和windows server 2008R2 sp1

有没有自己写的rman脚本,提上来试试看啊?

QaSanil 发表于 2012-10-16 19:39

回复 9# yihe_zang @REM $Header: hot_database_backup.cmd,v 1.3 from QaSanil 2005/11/28 19:01:53 $

@REM bcpyrght
@REM ***************************************************************************
@REM * $VRTScprght: Copyright 1993 - 2009 Symantec Corporation, All Rights Reserved $ *
@REM ***************************************************************************
@REM ecpyrght
@REM
@REM ---------------------------------------------------------------------------
@REM                        hot_database_backup.cmd
@REM ---------------------------------------------------------------------------
@REM This script uses Recovery Manager to take a hot (inconsistent) database
@REM backup. A hot backup is inconsistent because portions of the database are
@REM being modified and written to the disk while the backup is progressing.
@REM You must run your database in ARCHIVELOG mode to make hot backups.
@REM
@REM NOTE information for running proxy backups has been included.These
@REM information sections begin with a comment line of PROXY
@REM ---------------------------------------------------------------------------

@setlocal ENABLEEXTENSIONS

@REM ---------------------------------------------------------------------------
@REM No need to echo the commands.
@REM ---------------------------------------------------------------------------

@echo off

@REM ---------------------------------------------------------------------------
@REM Put output in the same filename, different extension.
@REM ---------------------------------------------------------------------------

@set RMAN_LOG_FILE="%~dpn0.out"

@REM ---------------------------------------------------------------------------
@REM You may want to delete the output file so that backup information does
@REM not accumulate.If not, delete the following command.
@REM ---------------------------------------------------------------------------

@if exist %RMAN_LOG_FILE% del %RMAN_LOG_FILE%

@REM ---------------------------------------------------------------------------
@REM Replace H:\oracle\ora81, below, with the Oracle home path.
@REM ---------------------------------------------------------------------------

@set ORACLE_HOME=D:\oracle\product\10.2.0\db_1

@REM ---------------------------------------------------------------------------
@REM Replace ora81, below, with the Oracle SID.
@REM ---------------------------------------------------------------------------

@set ORACLE_SID=oraoneb

@REM ---------------------------------------------------------------------------
@REM Replace sys/manager, below, with the target connect string.
@REM ---------------------------------------------------------------------------

@set TARGET_CONNECT_STR=sys/oracle

@REM ---------------------------------------------------------------------------
@REM Set the Oracle Recovery Manager.
@REM ---------------------------------------------------------------------------

@set RMAN=%ORACLE_HOME%\bin\rman.exe

@REM ---------------------------------------------------------------------------
@REM PROXY
@REM For a PROXY backup, uncomment the line below and replace the value.
@REM
@REM       NB_ORA_PC_STREAMS - specifies the number of parallel backup streams
@REM                           to be started.
@REM ---------------------------------------------------------------------------
@REM @set NB_ORA_PC_STREAMS=3


@REM ---------------------------------------------------------------------------
@REM Log the start of this scripts.
@REM ---------------------------------------------------------------------------

@for /F "tokens=1*" %%p in ('date /T') do @set DATE=%%p %%q
@for /F %%p in ('time /T') do @set DATE=%DATE% %%p

@echo ==== started on %DATE% ==== >> %RMAN_LOG_FILE%
@echo Script name: %0 >> %RMAN_LOG_FILE%

@REM ---------------------------------------------------------------------------
@REM Several RMAN commands use time parameters that require NLS_LANG and
@REM NLS_DATE_FORMAT to be set. This example uses the standard date format.
@REM Replace below with the desired language values.
@REM ---------------------------------------------------------------------------

@set NLS_LANG=american
@set NLS_DATE_FORMAT=YYYY-MM-DD:hh24:mi:ss

@REM ---------------------------------------------------------------------------
@REM Print out environment variables set in this script.
@REM ---------------------------------------------------------------------------

@echo #                                       >> %RMAN_LOG_FILE%
@echo   RMAN:%RMAN%                     >> %RMAN_LOG_FILE%
@echo   NLS_LANG:%NLS_LANG%               >> %RMAN_LOG_FILE%
@echo   ORACLE_HOME:%ORACLE_HOME%         >> %RMAN_LOG_FILE%
@echo   ORACLE_SID:%ORACLE_SID%         >> %RMAN_LOG_FILE%
@echo   NLS_DATE_FORMAT:%NLS_DATE_FORMAT% >> %RMAN_LOG_FILE%
@echo   RMAN_LOG_FILE:%RMAN_LOG_FILE%   >> %RMAN_LOG_FILE%

@REM ---------------------------------------------------------------------------
@REM PROXY
@REM For a PROXY backup, uncomment the line below.
@REM ---------------------------------------------------------------------------
@REM @echo   NB_ORA_PC_STREAMS:%NB_ORA_PC_STREAMS%   >> %RMAN_LOG_FILE%

@REM ---------------------------------------------------------------------------
@REM Print out environment variables set in bphdb.
@REM ---------------------------------------------------------------------------

@echo   NB_ORA_SERV:%NB_ORA_SERV%                     >> %RMAN_LOG_FILE%
@echo   NB_ORA_FULL:%NB_ORA_FULL%                     >> %RMAN_LOG_FILE%
@echo   NB_ORA_INCR:%NB_ORA_INCR%                     >> %RMAN_LOG_FILE%
@echo   NB_ORA_CINC:%NB_ORA_CINC%                     >> %RMAN_LOG_FILE%
@echo   NB_ORA_CLASS:%NB_ORA_CLASS%                   >> %RMAN_LOG_FILE%

@REM ---------------------------------------------------------------------------
@REM We assume that the database is properly opened. If desired, this would
@REM be the place to verify that.
@REM ---------------------------------------------------------------------------

@REM ---------------------------------------------------------------------------
@REM If this script is executed from a NetBackup schedule, NetBackup
@REM sets an NB_ORA environment variable based on the schedule type.
@REM For example, when:
@REM   schedule type is                BACKUP_TYPE is
@REM   ----------------                --------------
@REM Automatic Full                      INCREMENTAL LEVEL=0
@REM Automatic Differential IncrementalINCREMENTAL LEVEL=1
@REM Automatic Cumulative Incremental    INCREMENTAL LEVEL=1 CUMULATIVE
@REM
@REM For user initiated backups, BACKUP_TYPE defaults to incremental
@REM level 0 (Full).To change the default for a user initiated
@REM backup to incremental or incrementatl cumulative, uncomment
@REM one of the following two lines.
@REM @set BACKUP_TYPE="INCREMENTAL LEVEL=1"
@REM @set BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"
@REM
@REM Note that we use incremental level 0 to specify full backups.
@REM That is because, although they are identical in content, only
@REM the incremental level 0 backup can have incremental backups of
@REM level > 0 applied to it.
@REM ---------------------------------------------------------------------------

@REM ---------------------------------------------------------------------------
@REM What kind of backup will we perform.
@REM ---------------------------------------------------------------------------

@if "%NB_ORA_FULL%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=0
@if "%NB_ORA_INCR%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=1
@if "%NB_ORA_CINC%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=1 CUMULATIVE
@if NOT DEFINED BACKUP_TYPE @set BACKUP_TYPE=INCREMENTAL Level=0

@REM ---------------------------------------------------------------------------
@REM Call Recovery Manager to initiate the backup. This example does not use a
@REM Recovery Catalog. If you choose to use one, remove the option, nocatalog,
@REM from the rman command line below and add a
@REM 'rcvcat <userid>/<passwd>@<tns alias>' statement.
@REM
@REMNOTE WHEN USING TNS ALIAS: When connecting to a database
@REMusing a TNS alias, you must use a send command or a parms operand to
@REMspecify environment variables.In other words, when accessing a database
@REMthrough a listener, the environment variables set at the system level are not
@REMvisible when RMAN is running.For more information on the environment
@REMvariables, please refer to the NetBackup for Oracle Admin. Guide.
@REM
@REM If you are getting an error that the input line is too long, you will need
@REM to put the RMAN run block in a separate file.Then use the "cmdfile"
@REM option of RMAN.For more information on the "cmdfile" options please
@REM refer to the RMAN documentation.
@REM ---------------------------------------------------------------------------

@REM ---------------------------------------------------------------------------
@REM PROXY
@REM For a PROXY backup, you must use a send command to specify
@REM the NB_ORA_PC_STREAMS environment variable. For example,
@REM echo ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
@REM echo SEND 'NB_ORA_PC_STREAMS=%%NB_ORA_PC_STREAMS%%';
@REM
@REM %BACKUP_TYPE% must also be removed and replaced with the PROXY parameter
@REM in the RMAN section associated with the data files.For example,
@REM echo BACKUP
@REM echo       PROXY
@REM echo       FORMAT 'bk_u%%u_s%%s_p%%p_t%%t'
@REM echo       DATABASE;
@REM            .
@REM            .
@REMNote that the controlfiles and archivelogs are not backed up using proxy
@REMcopy method. Rman will initiate non-proxy copy sessions to backup the
@REMcontrolfile and archivelogs.
@REM ---------------------------------------------------------------------------
@(
echo RUN {
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
echo BACKUP
echo       %BACKUP_TYPE%
echo       FORMAT 'bk_u%%u_s%%s_p%%p_t%%t'
echo       DATABASE;
echo sql 'alter system archive log current';
echo RELEASE CHANNEL ch00;
echo RELEASE CHANNEL ch01;
echo # Backup all archive logs
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo BACKUP
echo       FILESPERSET 20
echo       FORMAT 'arch-s%%s-p%%p'
echo       ARCHIVELOG ALL;
echo RELEASE CHANNEL ch00;
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo BACKUP
echo       FORMAT 'cntrl_%s_%p_%t'
echo       CURRENT CONTROLFILE;
echo RELEASE CHANNEL ch00;
echo }
) | %RMAN% target %TARGET_CONNECT_STR% nocatalog msglog '%RMAN_LOG_FILE%' append

@set ERRLEVEL=%ERRORLEVEL%

@REM ---------------------------------------------------------------------------
@REM NetBackup (bphdb) stores the name of a file in an environment variable,
@REM called STATUS_FILE. This file is used by an automatic schedule to
@REM communicate status information with NetBackup's job monitor. It is up to
@REM the script to write a 0 (passed) or 1 (failure) to the status file.
@REM ---------------------------------------------------------------------------

@if %ERRLEVEL% NEQ 0 @goto err

@set LOGMSG=ended successfully
@if "%STATUS_FILE%" EQU "" goto end
@echo 0 > "%STATUS_FILE%"
@goto end

:err
@set LOGMSG=ended in error
@if "%STATUS_FILE%" EQU "" @goto end
@echo 1 > "%STATUS_FILE%"

:end

@REM ---------------------------------------------------------------------------
@REM Log the completion of this script.
@REM ---------------------------------------------------------------------------

@for /F "tokens=1*" %%p in ('date /T') do @set DATE=%%p %%q
@for /F %%p in ('time /T') do @set DATE=%DATE% %%p

@echo #>> %RMAN_LOG_FILE%
@echo %==== %LOGMSG% on %DATE% ==== >> %RMAN_LOG_FILE%
@endlocal
@REM End of Main Program -----------------------------------------------------
页: [1] 2
查看完整版本: NBU7备份Oracle for Windows的两种思路的区别