Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 
 

Oracle rman backups from  Windows Script

Oracle Database Tips by Donald Burleson

Scheduling tasks such as an Oracle rman backup can be challenging in a Windows environment without a third-party approach such as SFU, JavaScript or Visual Basic.  It's tricky, but you can write old-fashioned DOS bat files, a string of DOS prompt commands, to create an execute an Oracle rman backup.

Also see these related RMAN scriptsHere is yet another RMAN script that will monitor the progress of your RMAN script. Example of RMAN shell script.

Once tested, the bat file is invoked with the Windows AT scheduling command.

Lets examine an RMAN backup script. Note that we build the exp parfile arguments into a DOS variable called %PARFILE%, just like you can invoke Oracle directly from the DOS prompt: e.g.    

rman target %DB_USERNAME%/%DB_PASSWORD%@%TNS_ALIAS% 

Above, note that this is all on one line, an important consideration when doing DOS bat file scripting. 

REM +--------------------------------------------------------------------------+
REM | VALIDATE COMMAND-LINE PARAMETERS                                         |
REM +--------------------------------------------------------------------------+

if (%1)==() goto USAGE
if (%2)==() goto USAGE
if (%3)==() goto USAGE


REM +--------------------------------------------------------------------------+
REM | VALIDATE ENVIRONMENT VARIABLES                                           |
REM +--------------------------------------------------------------------------+

REM   set ORALOG=C:\oracle\custom\oracle\log
REM   set ORATMP=C:\oracle\custom\oracle\temp

if (%ORALOG%)==() goto ENV_VARIABLES
if (%ORATMP%)==() goto ENV_VARIABLES


REM +--------------------------------------------------------------------------+
REM | DECLARE ALL GLOBAL VARIABLES.                                            |
REM +--------------------------------------------------------------------------+

set FILENAME=rman_backup_hot_full_9i
set DB_USERNAME=%1%
set DB_PASSWORD=%2%
set TNS_ALIAS=%3%
set CMDFILE=%ORATMP%\%FILENAME%_%TNS_ALIAS%.rcv
set LOGFILE=%ORALOG%\%FILENAME%_%TNS_ALIAS%.log


REM +--------------------------------------------------------------------------+
REM | REMOVE OLD LOG AND RMAN COMMAND FILES.                                   |
REM +--------------------------------------------------------------------------+

del /q %CMDFILE%
del /q %LOGFILE%


REM +--------------------------------------------------------------------------+
REM | WRITE RMAN COMMAND SCRIPT.                                               |
REM +--------------------------------------------------------------------------+

echo backup database plus archivelog delete input; > %CMDFILE%
REM echo crosscheck backup of database; >> %CMDFILE%
REM echo crosscheck backup of controlfile; >> %CMDFILE%
REM echo crosscheck archivelog all; >> %CMDFILE%

echo delete noprompt force obsolete;>> %CMDFILE%
REM echo delete force noprompt expired backup of database; >> %CMDFILE%
REM echo delete force noprompt expired backup of controlfile; >> %CMDFILE%
REM echo delete force noprompt expired archivelog all; >> %CMDFILE%

echo exit; >> %CMDFILE%


REM +--------------------------------------------------------------------------+
REM | PERFORM RMAN BACKUP.                                                     |
REM +--------------------------------------------------------------------------+

rman target %DB_USERNAME%/%DB_PASSWORD%@%TNS_ALIAS% nocatalog cmdfile=%CMDFILE% msglog %LOGFILE%


REM +--------------------------------------------------------------------------+
REM | SCAN THE RMAN LOGFILE FOR ERRORS.                                        |
REM +--------------------------------------------------------------------------+

findstr /i "error" %LOGFILE%
if errorlevel 0 if not errorlevel 1 echo WARNING %FILENAME% %TNS_ALIAS% %COMPUTERNAME% %DATE% %TIME% %LOGFILE%

echo ...
echo END OF FILE REPORT
echo Filename      : %FILENAME%
echo Database      : %TNS_ALIAS%
echo Hostname      : %COMPUTERNAME%
echo Date          : %DATE%
echo Time          : %TIME%
echo RMAN Log File : %LOGFILE%


REM +--------------------------------------------------------------------------+
REM | END THIS SCRIPT.                                                         |
REM +--------------------------------------------------------------------------+

goto END



REM +==========================================================================+
REM |                    ***   END OF SCRIPT   ***                             |
REM +==========================================================================+

REM +--------------------------------------------------------------------------+
REM | LABEL DECLARATION SECTION.                                               |
REM +--------------------------------------------------------------------------+

:USAGE
echo Usage:  rman_backup_hot_full_9i.bat  DBA_USERNAME  DBA_PASSWORD  TNS_ALIAS
echo           DBA_USERNAME   = Oracle DBA Username - (Requires SYSDBA Role)
echo           DBA_PASSWORD   = Oracle DBA Password
echo           TNS_ALIAS      = Connect String to connect to the database (ex. ORCL)
goto END

:ENV_VARIABLES
echo ERROR:  You must set the following environment variables before
echo         running this script:
echo             ORALOG       = Directory used to write logfile to
echo             ORATMP       = Directory used to write temporary files to
goto END

:END
@echo on
 

 
   
Windows for the Oracle DBA

The landmark book Windows for the Oracle DBA is a comprehensive overview of everything an Oracle DBA needs to know to manage Oracle on Windows.  Order directly from Rampant and save 30%. 
 

 


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.