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

Free Oracle Tips

HTML Text

 Home
 E-mail Us
 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   


 

 

 


 

 

 

 
 

Oracle rman backups from  Windows Script

Oracle Tips by Burleson Consulting

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.

 For working examples of Oracle rman backups in Windows scripts, Jeff Hunter, author of "Conducting the Java Job Interview" has a great script to schedule an rman backup in a Windows environment.

Lets examine Hunter's rman backup script. Note that he builds 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 doping DOS bat file scripting.  Here is Jeff's code:

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
 

Oracle Backup & Recovery:
Expert secrets for using RMAN and Data Pump

Kamran Agayev Agamehdi & Aman Sharma

Only $35.95 with code download of working scripts.

 

 
 
  Guarantee your Success!

Oracle is the world's most complex, robust and flexible database, considered impossible to master without a mentor.

That's why all BC Oracle trainers are working professionals, experts in Oracle who share their tips and secrets.

 


 

 

  
 

 
 
 
 
Oracle performance tuning software
 
 

 

 
 
 
Oracle performance Tuning 10g reference poster
 
 
 
Oracle training in Linux commands
 
Oracle training Excel
 
Oracle training & performance tuning books
 

 

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 -  2011 by Burleson Enterprises

All rights reserved.

Oracle © is the registered trademark of Oracle Corporation.