免费注册 查看新帖 |

Chinaunix

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

[Veritas NBU] 跪求oracle10/11 on windows平台的rman脚本 for NBU7 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-10-12 17:26 |只看该作者 |倒序浏览
搞了许久,脚本和模版的备份都没有成功,哪位有没有现成的cmd脚本,贴出来参考一下啊?

论坛徽章:
0
2 [报告]
发表于 2012-10-12 20:56 |只看该作者
7.X 脚本确实有问题。

论坛徽章:
0
3 [报告]
发表于 2012-10-14 16:26 |只看该作者
回复 2# huanglao2002


    有没有搞成功过啊?就没有好用的脚本吗?分享一下啊!

有没有用NBU备份模版成功过的啊!

论坛徽章:
0
4 [报告]
发表于 2012-10-16 19:38 |只看该作者
楼主可以开个case叫他们发一个,或者用我的
  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, 下载次数: 58

论坛徽章:
0
5 [报告]
发表于 2012-10-20 12:21 |只看该作者
嗯,win下的7.x的脚本不能备份,一直用6.5的说

论坛徽章:
0
6 [报告]
发表于 2012-10-20 18:10 |只看该作者
可以用6.5的....

论坛徽章:
0
7 [报告]
发表于 2012-10-22 13:51 |只看该作者
回复 4# QaSanil


    老大很强哦,用了这么多的脚本,就你的成功了,一直以为是Oracle安装的问题呢!

看来还是脚本的事啊!

用BE来备份Oracle很简单,那不知道用be提供的rman脚本给nbu用的话能不能行呢?在哪里找到be提供的rman脚本呢?

论坛徽章:
0
8 [报告]
发表于 2012-10-22 15:14 |只看该作者
回复 7# yihe_zang


    求教无牙大大吧。我只是半瓶水。

论坛徽章:
0
9 [报告]
发表于 2012-11-06 10:08 |只看该作者
我用NBU备份Oralce一闪就完成,应该也是7的脚本问题,先下载,在测试下。谢谢分享。

论坛徽章:
0
10 [报告]
发表于 2012-11-19 16:10 |只看该作者
7.X的脚本是有问题,修改下就可以用了
echo off
setlocal ENABLEEXTENSIONS
set RMAN_LOG_FILE="%~dpn0.out"
if exist %RMAN_LOG_FILE% del %RMAN_LOG_FILE%
set ORACLE_HOME=d:\oracle\product\10.2.0\db_1
set ORACLE_SID=ecms
set TARGET_CONNECT_STR=backup/backup123
set RMAN=%ORACLE_HOME%\bin\rman.exe
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%
set NLS_LANG=american
set NLS_DATE_FORMAT=YYYY-MM-DD:hh24:mi:ss
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%

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%

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

(
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 DELETE INPUT;
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%'
set ERRLEVEL=%ERRORLEVEL%
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

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

echo on
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP