cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot backup oracle by hot_database_backup script

pellyaprai_prai
Level 3
Certified

Daer All

 

I want to backup oracle by hot_database_backup script.The script modified follow Italic lines.

 

@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=C:\app\Administrator\product\11.2.0\dbhome_1
 
@REM ---------------------------------------------------------------------------
@REM Replace ora102, below, with the Oracle SID.
@REM ---------------------------------------------------------------------------
 
@set ORACLE_SID=oracle
 
@REM ---------------------------------------------------------------------------
@REM Replace sys/manager, below, with the target connect string.
@REM ---------------------------------------------------------------------------
 
@set TARGET_CONNECT_STR=/
 
@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% catalog rman/rman@rcat1 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 -----------------------------------------------------
--------------------------------------------
 
And I create policy spectify backup selection to PATH_SCRIPT\hot_database_backup.cmd.Then run manual backup so the script export hot_database_backup.out follow
 
==== started on Tue 10/16/2012  09:33 ==== 
Script name: "C:\Script\hot_database_backup_oracle.cmd" 
#                                       
  RMAN  :  C:\app\Administrator\product\11.2.0\dbhome_1\bin\rman.exe                       
  NLS_LANG  :  american               
  ORACLE_HOME  :  C:\app\Administrator\product\11.2.0\dbhome_1         
  ORACLE_SID  :  oracle           
  NLS_DATE_FORMAT  :  YYYY-MM-DD:hh24:mi:ss 
  RMAN_LOG_FILE  :  "C:\Script\hot_database_backup_oracle.out"     
  NB_ORA_SERV  :  nbu                     
  NB_ORA_FULL  :  1                     
  NB_ORA_INCR  :  0                     
  NB_ORA_CINC  :  0                     
 
Recovery Manager: Release 11.2.0.3.0 - Production on Tue Oct 16 09:33:12 2012
 
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
 
connected to target database: ORACLE (DBID=1669795559)
connected to recovery catalog database
 
RMAN> 
 
Recovery Manager complete.
#   
 
But script is not backup database and job successfullly.When I run rman for manual backup and copy command in scprit put in rman and enter,it can backup database nomally and have jobs on activity monitor.
 
rman target oracle/oracle@oracle catalog rman/rman@rcat1
 
RMAN> RUN {
2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
3> ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
4> BACKUP
5> DATABASE;
6> RELEASE CHANNEL ch00;
7> RELEASE CHANNEL ch01;
8> }
 
allocated channel: ch00
channel ch00: SID=18 device type=SBT_TAPE
channel ch00: Veritas NetBackup for Oracle - Release 7.5 (20120916)
 
allocated channel: ch01
channel ch01: SID=133 device type=SBT_TAPE
channel ch01: Veritas NetBackup for Oracle - Release 7.5 (20120916)
 
Starting backup at 16-OCT-12
channel ch00: starting full datafile backup set
channel ch00: specifying datafile(s) in backup set
input datafile file number=00001 name=C:\APP\ADMINISTRATOR\ORADATA\ORACLE\SYSTEM
01.DBF
input datafile file number=00003 name=C:\APP\ADMINISTRATOR\ORADATA\ORACLE\UNDOTB
S01.DBF
channel ch00: starting piece 1 at 16-OCT-12
channel ch01: starting full datafile backup set
channel ch01: specifying datafile(s) in backup set
input datafile file number=00002 name=C:\APP\ADMINISTRATOR\ORADATA\ORACLE\SYSAUX
01.DBF
input datafile file number=00004 name=C:\APP\ADMINISTRATOR\ORADATA\ORACLE\USERS0
1.DBF
channel ch01: starting piece 1 at 16-OCT-12
channel ch01: finished piece 1 at 16-OCT-12
piece handle=07nnssmi_1_1 tag=TAG20121016T094801 comment=API Version 2.0,MMS Ver
sion 5.0.0.0
channel ch01: backup set complete, elapsed time: 00:00:45
channel ch01: starting full datafile backup set
channel ch01: specifying datafile(s) in backup set
including current control file in backup set
channel ch01: starting piece 1 at 16-OCT-12
channel ch00: finished piece 1 at 16-OCT-12
piece handle=06nnssmi_1_1 tag=TAG20121016T094801 comment=API Version 2.0,MMS Ver
sion 5.0.0.0
channel ch00: backup set complete, elapsed time: 00:01:22
channel ch00: starting full datafile backup set
channel ch00: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ch00: starting piece 1 at 16-OCT-12
channel ch01: finished piece 1 at 16-OCT-12
piece handle=08nnsso0_1_1 tag=TAG20121016T094801 comment=API Version 2.0,MMS Ver
sion 5.0.0.0
channel ch01: backup set complete, elapsed time: 00:00:50
channel ch00: finished piece 1 at 16-OCT-12
piece handle=09nnssp4_1_1 tag=TAG20121016T094801 comment=API Version 2.0,MMS Ver
sion 5.0.0.0
channel ch00: backup set complete, elapsed time: 00:00:25
Finished backup at 16-OCT-12
 
released channel: ch00
 
released channel: ch01
 
 
Please me to solv this problem and details server
Master Server:  Window 2003 R2
                       Netbackup 7.5.0.4
Oracle Client:  Window 2008 R2
                       Netbackup 7.5.0.4
                      oracle version  11.2.0.3.0
                      Archive : Enable

Best Regards,

 

1 ACCEPTED SOLUTION

Accepted Solutions

pellyaprai_prai
Level 3
Certified

Dear All

I can backup oracle successfully.I take solution follow http://www.symantec.com/business/support/index?page=content&id=TECH171912

 

Thank you for assistance .

Best Regards,

View solution in original post

4 REPLIES 4

Marianne
Level 6
Partner    VIP    Accredited Certified

We are not seeing 'input line too long' error, but it seems as if the entire sectio between
@( ...
echo RUN {
and 
echo }
) |
is being ignored.

Consider a separate cmd file as per these notes in the script:

 

@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.

RLeon
Moderator
Moderator
   VIP   

This maybe a long shot, but when you copy/modify the script, you have to make sure it is encoded in ANSI when it is saved.

pellyaprai_prai
Level 3
Certified

Dear All

I can backup oracle successfully.I take solution follow http://www.symantec.com/business/support/index?page=content&id=TECH171912

 

Thank you for assistance .

Best Regards,

Marianne
Level 6
Partner    VIP    Accredited Certified

Process in TECH171912 seems similar to when separate cmdfile is created...