免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 8472 | 回复: 11
打印 上一主题 下一主题

[Veritas NBU] NBU7备份Oracle for Windows的两种思路的区别 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-10-11 16:59 |只看该作者 |倒序浏览
请教各位大大,现在很少看到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)

第二种策略执行成功,但是没有备份数据:
  1. 2012/10/11 15:17:51 - Info nbjm(pid=3116) starting backup job (jobid=17) for client orcl, policy oracle-rman, schedule Full  
  2. 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})  
  3. 2012/10/11 15:17:51 - requesting resource be2012-disk
  4. 2012/10/11 15:17:51 - requesting resource be2012.NBU_CLIENT.MAXJOBS.orcl
  5. 2012/10/11 15:17:51 - requesting resource be2012.NBU_POLICY.MAXJOBS.oracle-rman
  6. 2012/10/11 15:17:51 - granted resource be2012.NBU_CLIENT.MAXJOBS.orcl
  7. 2012/10/11 15:17:51 - granted resource be2012.NBU_POLICY.MAXJOBS.oracle-rman
  8. 2012/10/11 15:17:51 - granted resource be2012-disk
  9. 2012/10/11 15:17:51 - estimated 0 Kbytes needed
  10. 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
  11. 2012/10/11 15:17:51 - started process bpbrm (5052)
  12. 2012/10/11 15:17:52 - Info bpbrm(pid=5052) orcl is the host to backup data from     
  13. 2012/10/11 15:17:52 - Info bpbrm(pid=5052) reading file list from client        
  14. 2012/10/11 15:17:52 - connecting
  15. 2012/10/11 15:17:55 - Info bpbrm(pid=5052) starting bphdb on client         
  16. 2012/10/11 15:17:55 - Info bphdb(pid=3420) Backup started           
  17. 2012/10/11 15:17:55 - connected; connect time: 00:00:03
  18. 2012/10/11 15:17:57 - Info bpbrm(pid=5052) validating image for client orcl        
  19. 2012/10/11 15:17:59 - end writing
  20. the requested operation was successfully completed(0)
复制代码
还请高手指教啊!

论坛徽章:
1
CU十二周年纪念徽章
日期:2013-10-24 15:41:34
2 [报告]
发表于 2012-10-11 18:30 |只看该作者
两个方法没什太大的区别。 应该是配置上的问导致备份失败。

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

论坛徽章:
0
3 [报告]
发表于 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 Incremental  INCREMENTAL 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
@REM  NOTE WHEN USING NET SERVICE NAME: When connecting to a database
@REM  using a net service name, you must use a send command or a parms operand to
@REM  specify environment variables.  In other words, when accessing a database
@REM  through a listener, the environment variables set at the system level are not
@REM  visible when RMAN is running.  For more information on the environment
@REM  variables, 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 -----------------------------------------------------

论坛徽章:
0
4 [报告]
发表于 2012-10-12 12:13 |只看该作者
@set ORACLE_SID=orcl

@set TARGET_CONNECT_STR=sys/redhat123

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

回复 3# yihe_zang


   

论坛徽章:
0
5 [报告]
发表于 2012-10-12 13:23 |只看该作者
回复 4# liu3231


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

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

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

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

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

  18. RMAN>

  19. Recovery Manager complete.
  20. #   
复制代码

论坛徽章:
0
6 [报告]
发表于 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
以上两行需要保留。

论坛徽章:
0
7 [报告]
发表于 2012-10-13 00:09 |只看该作者
备份一闪而过的问题,我之前就碰到过了,换成6.X的脚本就可以
至于楼上的方法,是否可行?实践过么

论坛徽章:
0
8 [报告]
发表于 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的
个人认为,欢迎拍砖,楼下补充。

论坛徽章:
0
9 [报告]
发表于 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脚本,提上来试试看啊?

论坛徽章:
0
10 [报告]
发表于 2012-10-16 19:39 |只看该作者
回复 9# yihe_zang
  1. @REM $Header: hot_database_backup.cmd,v 1.3 from QaSanil 2005/11/28 19:01:53 $

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

  19. @setlocal ENABLEEXTENSIONS

  20. @REM ---------------------------------------------------------------------------
  21. @REM No need to echo the commands.
  22. @REM ---------------------------------------------------------------------------

  23. @echo off

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

  27. @set RMAN_LOG_FILE="%~dpn0.out"

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

  32. @if exist %RMAN_LOG_FILE% del %RMAN_LOG_FILE%

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

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

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

  40. @set ORACLE_SID=oraoneb

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

  44. @set TARGET_CONNECT_STR=sys/oracle

  45. @REM ---------------------------------------------------------------------------
  46. @REM Set the Oracle Recovery Manager.
  47. @REM ---------------------------------------------------------------------------

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

  49. @REM ---------------------------------------------------------------------------
  50. @REM PROXY
  51. @REM For a PROXY backup, uncomment the line below and replace the value.
  52. @REM
  53. @REM       NB_ORA_PC_STREAMS - specifies the number of parallel backup streams
  54. @REM                           to be started.
  55. @REM ---------------------------------------------------------------------------
  56. @REM @set NB_ORA_PC_STREAMS=3


  57. @REM ---------------------------------------------------------------------------
  58. @REM Log the start of this scripts.
  59. @REM ---------------------------------------------------------------------------

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

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

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

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

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

  74. @echo #                                       >> %RMAN_LOG_FILE%
  75. @echo   RMAN  :  %RMAN%                       >> %RMAN_LOG_FILE%
  76. @echo   NLS_LANG  :  %NLS_LANG%               >> %RMAN_LOG_FILE%
  77. @echo   ORACLE_HOME  :  %ORACLE_HOME%         >> %RMAN_LOG_FILE%
  78. @echo   ORACLE_SID  :  %ORACLE_SID%           >> %RMAN_LOG_FILE%
  79. @echo   NLS_DATE_FORMAT  :  %NLS_DATE_FORMAT% >> %RMAN_LOG_FILE%
  80. @echo   RMAN_LOG_FILE  :  %RMAN_LOG_FILE%     >> %RMAN_LOG_FILE%

  81. @REM ---------------------------------------------------------------------------
  82. @REM PROXY
  83. @REM For a PROXY backup, uncomment the line below.
  84. @REM ---------------------------------------------------------------------------
  85. @REM @echo   NB_ORA_PC_STREAMS  :  %NB_ORA_PC_STREAMS%     >> %RMAN_LOG_FILE%

  86. @REM ---------------------------------------------------------------------------
  87. @REM Print out environment variables set in bphdb.
  88. @REM ---------------------------------------------------------------------------

  89. @echo   NB_ORA_SERV  :  %NB_ORA_SERV%                     >> %RMAN_LOG_FILE%
  90. @echo   NB_ORA_FULL  :  %NB_ORA_FULL%                     >> %RMAN_LOG_FILE%
  91. @echo   NB_ORA_INCR  :  %NB_ORA_INCR%                     >> %RMAN_LOG_FILE%
  92. @echo   NB_ORA_CINC  :  %NB_ORA_CINC%                     >> %RMAN_LOG_FILE%
  93. @echo   NB_ORA_CLASS  :  %NB_ORA_CLASS%                   >> %RMAN_LOG_FILE%

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

  98. @REM ---------------------------------------------------------------------------
  99. @REM If this script is executed from a NetBackup schedule, NetBackup
  100. @REM sets an NB_ORA environment variable based on the schedule type.
  101. @REM For example, when:
  102. @REM     schedule type is                BACKUP_TYPE is
  103. @REM     ----------------                --------------
  104. @REM Automatic Full                      INCREMENTAL LEVEL=0
  105. @REM Automatic Differential Incremental  INCREMENTAL LEVEL=1
  106. @REM Automatic Cumulative Incremental    INCREMENTAL LEVEL=1 CUMULATIVE
  107. @REM
  108. @REM For user initiated backups, BACKUP_TYPE defaults to incremental
  109. @REM level 0 (Full).  To change the default for a user initiated
  110. @REM backup to incremental or incrementatl cumulative, uncomment
  111. @REM one of the following two lines.
  112. @REM @set BACKUP_TYPE="INCREMENTAL LEVEL=1"
  113. @REM @set BACKUP_TYPE="INCREMENTAL LEVEL=1 CUMULATIVE"
  114. @REM
  115. @REM Note that we use incremental level 0 to specify full backups.
  116. @REM That is because, although they are identical in content, only
  117. @REM the incremental level 0 backup can have incremental backups of
  118. @REM level > 0 applied to it.
  119. @REM ---------------------------------------------------------------------------

  120. @REM ---------------------------------------------------------------------------
  121. @REM What kind of backup will we perform.
  122. @REM ---------------------------------------------------------------------------

  123. @if "%NB_ORA_FULL%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=0
  124. @if "%NB_ORA_INCR%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=1
  125. @if "%NB_ORA_CINC%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=1 CUMULATIVE
  126. @if NOT DEFINED BACKUP_TYPE @set BACKUP_TYPE=INCREMENTAL Level=0

  127. @REM ---------------------------------------------------------------------------
  128. @REM Call Recovery Manager to initiate the backup. This example does not use a
  129. @REM Recovery Catalog. If you choose to use one, remove the option, nocatalog,
  130. @REM from the rman command line below and add a
  131. @REM 'rcvcat <userid>/<passwd>@<tns alias>' statement.
  132. @REM
  133. @REM  NOTE WHEN USING TNS ALIAS: When connecting to a database
  134. @REM  using a TNS alias, you must use a send command or a parms operand to
  135. @REM  specify environment variables.  In other words, when accessing a database
  136. @REM  through a listener, the environment variables set at the system level are not
  137. @REM  visible when RMAN is running.  For more information on the environment
  138. @REM  variables, please refer to the NetBackup for Oracle Admin. Guide.
  139. @REM
  140. @REM If you are getting an error that the input line is too long, you will need
  141. @REM to put the RMAN run block in a separate file.  Then use the "cmdfile"
  142. @REM option of RMAN.  For more information on the "cmdfile" options please
  143. @REM refer to the RMAN documentation.
  144. @REM ---------------------------------------------------------------------------

  145. @REM ---------------------------------------------------------------------------
  146. @REM PROXY
  147. @REM For a PROXY backup, you must use a send command to specify
  148. @REM the NB_ORA_PC_STREAMS environment variable. For example,
  149. @REM echo ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
  150. @REM echo SEND 'NB_ORA_PC_STREAMS=%%NB_ORA_PC_STREAMS%%';
  151. @REM
  152. @REM %BACKUP_TYPE% must also be removed and replaced with the PROXY parameter
  153. @REM in the RMAN section associated with the data files.  For example,
  154. @REM echo BACKUP
  155. @REM echo       PROXY
  156. @REM echo       FORMAT 'bk_u%%u_s%%s_p%%p_t%%t'
  157. @REM echo       DATABASE;
  158. @REM            .
  159. @REM            .
  160. @REM  Note that the controlfiles and archivelogs are not backed up using proxy
  161. @REM  copy method. Rman will initiate non-proxy copy sessions to backup the
  162. @REM  controlfile and archivelogs.
  163. @REM ---------------------------------------------------------------------------
  164. @(
  165. echo RUN {
  166. echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
  167. echo ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
  168. echo BACKUP
  169. echo       %BACKUP_TYPE%
  170. echo       FORMAT 'bk_u%%u_s%%s_p%%p_t%%t'
  171. echo       DATABASE;
  172. echo sql 'alter system archive log current';
  173. echo RELEASE CHANNEL ch00;
  174. echo RELEASE CHANNEL ch01;
  175. echo # Backup all archive logs
  176. echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
  177. echo BACKUP
  178. echo       FILESPERSET 20
  179. echo       FORMAT 'arch-s%%s-p%%p'
  180. echo       ARCHIVELOG ALL;
  181. echo RELEASE CHANNEL ch00;
  182. echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
  183. echo BACKUP
  184. echo       FORMAT 'cntrl_%s_%p_%t'
  185. echo       CURRENT CONTROLFILE;
  186. echo RELEASE CHANNEL ch00;
  187. echo }
  188. ) | %RMAN% target %TARGET_CONNECT_STR% nocatalog msglog '%RMAN_LOG_FILE%' append

  189. @set ERRLEVEL=%ERRORLEVEL%

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

  196. @if %ERRLEVEL% NEQ 0 @goto err

  197. @set LOGMSG=ended successfully
  198. @if "%STATUS_FILE%" EQU "" goto end
  199. @echo 0 > "%STATUS_FILE%"
  200. @goto end

  201. :err
  202. @set LOGMSG=ended in error
  203. @if "%STATUS_FILE%" EQU "" @goto end
  204. @echo 1 > "%STATUS_FILE%"

  205. :end

  206. @REM ---------------------------------------------------------------------------
  207. @REM Log the completion of this script.
  208. @REM ---------------------------------------------------------------------------

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

  211. @echo #  >> %RMAN_LOG_FILE%
  212. @echo %==== %LOGMSG% on %DATE% ==== >> %RMAN_LOG_FILE%
  213. @endlocal
  214. @REM End of Main Program -----------------------------------------------------
复制代码
hot_database_backup.7z (2.98 KB, 下载次数: 1106)
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP