@setlocal ENABLEEXTENSIONS
@REM
-----------------------------------------------------------------
@REM Backup script generated on 06/27/12 11:31:30
@REM Shell Script name: test.cmd
@REM
@REM Veritas NetBackup for oracle on Windows
@REM $VRTScprght: Copyright 1993 - 2012 Symantec Corporation, All
Rights Reserved $
@REM
-----------------------------------------------------------------
@set RMAN_LOG_FILE="%~dpn0.out"
@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=�TE% %%p
@echo Script %0 > %RMAN_LOG_FILE%
@echo ==== started on �TE% ==== >>
%RMAN_LOG_FILE%
@set
ORACLE_HOME=H:\oracle\product\10.2.0\db_1 (需要修改)
@set ORACLE_SID=orcl (需要修改)
@set TARGET_CONNECT_STR=sys/xxx@orcl(需要修改)
@set RMAN=%ORACLE_HOME%\bin\rman.exe
@REM
-----------------------------------------------------------------
@REM The NetBackup Policy that would have been used when this
script
@REM was generated could not be determined. BACKUP_TYPE is
derived
@REM from the Policy and must be set to sucessfully run this
script.
@REM Select one of the following to reflect the backup type of
the
@REM Policy that will be used when this script is executed.
@REM
-----------------------------------------------------------------
@REM
-----------------------------------------------------------------
@REM Uncomment the next statement if the backup type of the
Policy
@REM will be, Block Level Incremental, Snapshot, Instant
Recovery
@REM Alternate Client Snapshot, or Instant Recovery to Storage
Unit.
@REM If using one of these NetBackup backup methods with Oracle
RMAN
@REM you may want to configure the number of proxy backup streams
by
@REM adding NB_ORA_PC_STREAMS=
streams> to the SEND command.
@REM
-----------------------------------------------------------------
@REM @set BACKUP_TYPE=PROXY
@REM
-----------------------------------------------------------------
@REM If the Policy backup type is a standard Oracle RMAN backup
and
@REM the script is executed from a NetBackup schedule,
NetBackup
@REM sets an NB_ORA environment variable based on the schedule
type.
@REM The NB_ORA variable is then used to dynamically set
BACKUP_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 For user initiated backups BACKUP_TYPE defaults to
incremental
@REM level 0 (full). To change this default to incremental or
@REM incremental cumulative, replace INCREMENTAL LEVEL=0 with
@REM INCREMENTAL LEVEL=1 or INCREMENTAL LEVEL=1 CUMULATIVE in
@REM the line below that contains, "@if NOT DEFINED
BACKUP_TYPE".
@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
@REM of level > 0 applied to it.
@REM Uncomment the commands below if the Oracle Policy backup
type
@REM will be Standard (i.e. non-proxy).
@REM
-----------------------------------------------------------------
@REM @if "%NB_ORA_FULL%" EQU
"1" @set
BACKUP_TYPE=INCREMENTAL LEVEL=0
@REM @if "%NB_ORA_INCR%" EQU
"1" @set
BACKUP_TYPE=INCREMENTAL LEVEL=1
@REM @if "%NB_ORA_CINC%" EQU
"1" @set
BACKUP_TYPE=INCREMENTAL LEVEL=1 CUMULATIVE
@REM @if NOT DEFINED
BACKUP_TYPE @set
BACKUP_TYPE=INCREMENTAL LEVEL=0
@REM
-----------------------------------------------------------------
@REM rman commands for database orcl.
@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 SEND
'NB_ORA_CLIENT=XXX,NB_ORA_SID=orcl,NB_ORA_SERV=XXX';
(需要修改)echo BACKUP �CKUP_TYPE% FORMAT
'bk_u%%u_s%%s_p%%p_t%%t' DATABASE;
echo RELEASE CHANNEL ch00;
echo # Backup Archived Logs
echo # For an offline backup, remove the following sql
statement
echo sql 'alter system archive log current';
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo SEND
'NB_ORA_CLIENT=XXX,NB_ORA_SID=orcl,NB_ORA_SERV=XXX';
(需要修改)
echo BACKUP FORMAT 'arch_u%%u_s%%s_p%%p_t%%t' ARCHIVELOG ALL
DELETE INPUT;
echo RELEASE CHANNEL ch00;
echo # Control file backup
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo SEND
'NB_ORA_CLIENT=XXX,NB_ORA_SID=orcl,NB_ORA_SERV=XXX';
(需要修改)
echo BACKUP FORMAT 'ctrl_u%%u_s%%s_p%%p_t%%t' CURRENT
CONTROLFILE;
echo RELEASE CHANNEL ch00;
echo }
) | %RMAN% target %TARGET_CONNECT_STR% nocatalog msglog
'%RMAN_LOG_FILE%' append
@set ERRLEVEL=%ERRORLEVEL%
@REM
-----------------------------------------------------------------
@REM When this script is started as part of a scheduled
@REM backup, STATUS_FILE is used to communicate status
@REM information to the NetBackup job monitor.
@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=�TE% %%p
@echo Script %0 >>
%RMAN_LOG_FILE%
@echo ==== %LOGMSG% on �TE% ==== >>
%RMAN_LOG_FILE%
@endlocal
后记为了这么一个脚本反复折腾了好几天。留下来给需要的人。