Skip to main content
Template batch file and RMAN script for Windows RMAN hosts
Updated over a week ago

Enterprise Workloads Editions: βœ… Business | βœ… Enterprise | βœ… Elite

Druva provides a template batch file and an RMAN script for Windows RMAN hosts that you can use to backup databases. The scripts are:

  • oracle_rman_backup.bat: This batch file runs the RMAN script that backs up a database. You can modify this script to provide RMAN parameters that specify the type of backup and information related to backup like filesperset and channels for a backup.

  • rman_backup_windows.rman: This script runs the backup job on RMAN.

Druva provides the following scripts to enhance the backup performance and also provides extended recovery windows locally on PBS:

  • oracle_rman_data_full_merge_weekly_backup_windows: This script recovers and applies incremental backup set copies to the full image base copies of the backup. You can schedule this script to run on crontab based on the recovery window. For example, if the recovery window is set to 7 days, this script can be scheduled to run every week and the incremental backup pieces will be applied to the full image copies once every week.

  • oracle_rman_data_incremental_daily_backup_windows: This script backs up only incremental backups without performing recovery operations. You can schedule this script to run daily and ensure a recovery window from local PBS up to 7 days or based on the rman retention set for recovery window.


    πŸ“ Note
    ​The recovery window resets once the full merge script is run and hence you cannot recover your database from PBS to older backups that were backed up in the previous week.


The following sections provide the contents of the batch file and the RMAN script. You can edit these scripts to suit your requirements.

Template scripts for Phoenix Backup Store with version 4.9.1 or later


❗ Important

Druva requires you to use the following template scripts for Phoenix Backup Store with version 4.9.1 or later.


oracle_rman_backup.bat

echo off if not "%~2"=="" if "%~3"=="" goto START echo This script requires the next parameters: echo - backup_store_ip mount_name echo - backup_store_ip : IP of backup store echo - mount_name : backup mount name as in CPortal goto EOF :START echo Starting Backup setlocal enableDelayedExpansion enableextensions for /F "tokens=*" %%I in ('curl -X GET http://%1:9090/druva-phoenix/v1/mounts/%2/1.2/backup') do set validate_curl_output=%%I set VALIDATE_JSON=%validate_curl_output% set "VALIDATE_JSON=%VALIDATE_JSON:~1,-1%" set "VALIDATE_JSON=%VALIDATE_JSON:":=",%" set /a vcount = 0 REM Check for validate response for %%I in (%VALIDATE_JSON%) do ( if !vcount! == 1 ( if /I NOT %%I == 0 ( echo Request to validate backup failed, exiting echo Response from Phoenix Backup Store %VALIDATE_JSON% exit /b 1 ) else ( echo Request to validate backup succeeded ) ) REM is_max_snapshot_reached if !vcount! == 6 ( if %%I == true ( echo Maximum Pending Snapshot limit on PBS is reached. echo Request to validate backup failed, exiting echo Response from Phoenix Backup Store %VALIDATE_JSON% exit /b 1 ) ) set /a "vcount+=1" ) echo Validation Succeeded. Calling Start Backup for /F %%I in ('curl -X POST http://%1:9090/druva-phoenix/v1/mounts/%2/backup') do set curl_output=%%I set JSON=%curl_output% echo OUTPUT %curl_output% set "JSON=%JSON:~1,-1%" set "JSON=%JSON:":=",%" set /a count = 0 for %%I in (%JSON%) do ( if !count! == 1 ( if /I NOT %%I == 0 ( echo Request to start backup failed, exiting echo Response from Phoenix Backup Store %JSON% exit /b 1 ) else ( echo Request to start backup succeeded ) ) if !count! == 6 ( set mount_name=%%~I ) if !count! == 13 ( set mount_path=%%~I ) set /a "count+=1" ) set mount_path=%mount_path:~,-2% echo %mount_path% set mount_path=!mount_path:/=\! echo %mount_path% set complete_mount=\\%1%mount_path% echo %complete_mount% echo Mount name %mount_name% echo NFS mount path %complete_mount% if not exist %complete_mount%\full ( echo Creating directory %complete_mount%\full mkdir %complete_mount%\full if !ERRORLEVEL! NEQ 0 ( echo Unable to create directory %complete_mount%\full.. exiting exit /b ) ) REM Calling RMAN Backup on PBS for /F %%I in ('curl -X POST http://%1:9090/druva-phoenix/v1/mounts/%2/WIN/full/rmanbackup') do set rman_curl_output=%%I set RMAN_JSON=%rman_curl_output% echo Response of rman backup: %RMAN_JSON% set "RMAN_JSON=%RMAN_JSON:~1,-1%" set "RMAN_JSON=%RMAN_JSON:":=",%" set /a count = 0 for %%I in (%RMAN_JSON%) do ( if !count! == 1 ( if /I NOT %%I == 0 ( echo Request to start backup failed, exiting echo Response from Phoenix Backup Store %RMAN_JSON% exit /b 1 ) else ( echo Request to start backup succeeded ) ) if !count! == 15 ( echo Setting Snapshot Name: %%I set SNAP_NAME=%%~I ) set /a "count+=1" ) set SNAP_NAME=%SNAP_NAME:~,-2% echo Snapshot to be created: %SNAP_NAME% REM set SNAP_NAME="" if %SNAP_NAME% == "" ( echo "Empty Snapshot Name. Exiting." exit /b ) set LOG_FILE_DIR=%complete_mount%\_workspace\RMAN_Logs echo LOG FILE DIR IS := %LOG_FILE_DIR% if not exist %LOG_FILE_DIR% ( mkdir %LOG_FILE_DIR% if !ERRORLEVEL! NEQ 0 ( echo Unable to create directory %LOG_FILE_DIR.. exiting exit /b ) ) set RMAN_LOGFILE=%LOG_FILE_DIR%\rman_full_backup_%SNAP_NAME%_WIN.log rman log=%RMAN_LOGFILE% @rman_backup_windows.rman using '%complete_mount%' if !ERRORLEVEL! NEQ 0 ( echo RMAN backup failed. Check RMAN log %RMAN_LOGFILE% for the details exit /b ) echo RMAN backup completed echo Notifying Phoenix to upload RMAN Logs for /F %%I in ('curl -X POST -H "Content-Type: multipart/form-data" -F "file=@%RMAN_LOGFILE%" -F "mountpoint=%complete_mount%" -F "platform=windows" http://%1:9090/druva-phoenix/v1/mounts/%2/uploadlog') do set rman_upload_log_curl_output=%%I echo Response from Phoenix Backup Store for upload RMAN Log: %rman_upload_log_curl_output% echo Calling End Backup for /F %%I in ('curl -X PUT http://%1:9090/druva-phoenix/v1/mounts/%2/backup') do set curl_output2=%%I echo Response from Phoenix Backup Store : %curl_output2% :EOF exit /b

oracle_rman_data_full_merge_weekly_backup_windows.bat

echo off if not "%~2"=="" if "%~3"=="" goto START echo This script requires the next parameters: echo - backup_store_ip mount_name echo - backup_store_ip : IP of backup store echo - mount_name : backup mount name as in CPortal goto EOF :START echo Starting Backup setlocal enableDelayedExpansion enableextensions for /F "tokens=*" %%I in ('curl -X GET http://%1:9090/druva-phoenix/v1/mounts/%2/1.2/backup') do set validate_curl_output=%%I set VALIDATE_JSON=%validate_curl_output% set "VALIDATE_JSON=%VALIDATE_JSON:~1,-1%" set "VALIDATE_JSON=%VALIDATE_JSON:":=",%" set /a vcount = 0 REM Check for validate response for %%I in (%VALIDATE_JSON%) do ( if !vcount! == 1 ( if /I NOT %%I == 0 ( echo Request to validate backup failed, exiting echo Response from Phoenix Backup Store %VALIDATE_JSON% exit /b 1 ) else ( echo Request to validate backup succeeded ) ) REM is_max_snapshot_reached if !vcount! == 6 ( if %%I == true ( echo Maximum Pending Snapshot limit on PBS is reached. echo Request to validate backup failed, exiting echo Response from Phoenix Backup Store %VALIDATE_JSON% exit /b 1 ) ) set /a "vcount+=1" ) echo Validation Succeeded. Calling Start Backup for /F %%I in ('curl -X POST http://%1:9090/druva-phoenix/v1/mounts/%2/backup') do set curl_output=%%I set JSON=%curl_output% echo OUTPUT %curl_output% set "JSON=%JSON:~1,-1%" set "JSON=%JSON:":=",%" set /a count = 0 for %%I in (%JSON%) do ( if !count! == 1 ( if /I NOT %%I == 0 ( echo Request to start backup failed, exiting echo Response from Phoenix Backup Store %JSON% exit /b 1 ) else ( echo Request to start backup succeeded ) ) if !count! == 6 ( set mount_name=%%~I ) if !count! == 13 ( set mount_path=%%~I ) set /a "count+=1" ) set mount_path=%mount_path:~,-2% echo %mount_path% set mount_path=!mount_path:/=\! echo %mount_path% set complete_mount=\\%1%mount_path% echo %complete_mount% echo Mount name %mount_name% echo NFS mount path %complete_mount% if not exist %complete_mount%\full ( echo Creating directory %complete_mount%\full mkdir %complete_mount%\full if !ERRORLEVEL! NEQ 0 ( echo Unable to create directory %complete_mount%\full.. exiting exit /b ) ) REM Calling RMAN Backup on PBS for /F %%I in ('curl -X POST http://%1:9090/druva-phoenix/v1/mounts/%2/WIN/full/rmanbackup') do set rman_curl_output=%%I set RMAN_JSON=%rman_curl_output% echo Response of rman backup: %RMAN_JSON% set "RMAN_JSON=%RMAN_JSON:~1,-1%" set "RMAN_JSON=%RMAN_JSON:":=",%" set /a count = 0 for %%I in (%RMAN_JSON%) do ( if !count! == 1 ( if /I NOT %%I == 0 ( echo Request to start backup failed, exiting echo Response from Phoenix Backup Store %RMAN_JSON% exit /b 1 ) else ( echo Request to start backup succeeded ) ) if !count! == 15 ( echo Setting Snapshot Name: %%I set SNAP_NAME=%%~I ) set /a "count+=1" ) set SNAP_NAME=%SNAP_NAME:~,-2% echo Snapshot to be created: %SNAP_NAME% REM set SNAP_NAME="" if %SNAP_NAME% == "" ( echo "Empty Snapshot Name. Exiting." exit /b ) set LOG_FILE_DIR=%complete_mount%\_workspace\RMAN_Logs echo LOG FILE DIR IS := %LOG_FILE_DIR% if not exist %LOG_FILE_DIR% ( mkdir %LOG_FILE_DIR% if !ERRORLEVEL! NEQ 0 ( echo Unable to create directory %LOG_FILE_DIR.. exiting exit /b ) ) set RMAN_LOGFILE=%LOG_FILE_DIR%\rman_full_backup_%SNAP_NAME%_WIN.log rman log=%RMAN_LOGFILE% @oracle_rman_data_full_merge_weekly_backup_windows.rman using '%complete_mount%' if !ERRORLEVEL! NEQ 0 ( echo RMAN backup failed. Check RMAN log %RMAN_LOGFILE% for the details exit /b ) echo RMAN backup completed echo Notifying Phoenix to upload RMAN Logs for /F %%I in ('curl -X POST -H "Content-Type: multipart/form-data" -F "file=@%RMAN_LOGFILE%" -F "mountpoint=%complete_mount%" -F "platform=windows" http://%1:9090/druva-phoenix/v1/mounts/%2/uploadlog') do set rman_upload_log_curl_output=%%I echo Response from Phoenix Backup Store for upload RMAN Log: %rman_upload_log_curl_output% echo Calling End Backup for /F %%I in ('curl -X PUT http://%1:9090/druva-phoenix/v1/mounts/%2/backup') do set curl_output2=%%I echo Response from Phoenix Backup Store : %curl_output2% :EOF exit /b

oracle_rman_data_full_merge_weekly_backup_windows.rman

connect target / set echo on; configure backup optimization on; configure controlfile autobackup on; configure device type disk parallelism 1 BACKUP TYPE TO COPY; configure datafile backup copies for device type disk to 1; configure archivelog backup copies for device type disk to 1; configure channel device type disk format '&1\full\full_bk_datafile_%U.rbk'; configure controlfile autobackup format for device type disk to '&1\full\full_bk_controlfile_%F'; run { recover copy of database with tag 'phoenix_oracle_backup'; backup incremental level 1 for recover of copy with tag 'phoenix_oracle_backup' database; backup format '&1\full\full_bk_Archivelog_%d_%s_%t' archivelog all not backed up; #Force is to ignore I/O errors delete noprompt obsolete device type disk; delete force NOPROMPT expired copy; delete force NOPROMPT expired backup; crosscheck backup; crosscheck copy; } configure backup optimization clear; configure controlfile autobackup clear; exit

oracle_rman_data_incremental_daily_backup_windows.bat

echo off if not "%~2"=="" if "%~3"=="" goto START echo This script requires the next parameters: echo - backup_store_ip mount_name echo - backup_store_ip : IP of backup store echo - mount_name : backup mount name as in CPortal goto EOF :START echo Starting Backup setlocal enableDelayedExpansion enableextensions for /F "tokens=*" %%I in ('curl -X GET http://%1:9090/druva-phoenix/v1/mounts/%2/1.2/backup') do set validate_curl_output=%%I set VALIDATE_JSON=%validate_curl_output% set "VALIDATE_JSON=%VALIDATE_JSON:~1,-1%" set "VALIDATE_JSON=%VALIDATE_JSON:":=",%" set /a vcount = 0 REM Check for validate response for %%I in (%VALIDATE_JSON%) do ( if !vcount! == 1 ( if /I NOT %%I == 0 ( echo Request to validate backup failed, exiting echo Response from Phoenix Backup Store %VALIDATE_JSON% exit /b 1 ) else ( echo Request to validate backup succeeded ) ) REM is_max_snapshot_reached if !vcount! == 6 ( if %%I == true ( echo Maximum Pending Snapshot limit on PBS is reached. echo Request to validate backup failed, exiting echo Response from Phoenix Backup Store %VALIDATE_JSON% exit /b 1 ) ) set /a "vcount+=1" ) echo Validation Succeeded. Calling Start Backup for /F %%I in ('curl -X POST http://%1:9090/druva-phoenix/v1/mounts/%2/backup') do set curl_output=%%I set JSON=%curl_output% echo OUTPUT %curl_output% set "JSON=%JSON:~1,-1%" set "JSON=%JSON:":=",%" set /a count = 0 for %%I in (%JSON%) do ( if !count! == 1 ( if /I NOT %%I == 0 ( echo Request to start backup failed, exiting echo Response from Phoenix Backup Store %JSON% exit /b 1 ) else ( echo Request to start backup succeeded ) ) if !count! == 6 ( set mount_name=%%~I ) if !count! == 13 ( set mount_path=%%~I ) set /a "count+=1" ) set mount_path=%mount_path:~,-2% echo %mount_path% set mount_path=!mount_path:/=\! echo %mount_path% set complete_mount=\\%1%mount_path% echo %complete_mount% echo Mount name %mount_name% echo NFS mount path %complete_mount% if not exist %complete_mount%\full ( echo Creating directory %complete_mount%\full mkdir %complete_mount%\full if !ERRORLEVEL! NEQ 0 ( echo Unable to create directory %complete_mount%\full.. exiting exit /b ) ) REM Calling RMAN Backup on PBS for /F %%I in ('curl -X POST http://%1:9090/druva-phoenix/v1/mounts/%2/WIN/full/rmanbackup') do set rman_curl_output=%%I set RMAN_JSON=%rman_curl_output% echo Response of rman backup: %RMAN_JSON% set "RMAN_JSON=%RMAN_JSON:~1,-1%" set "RMAN_JSON=%RMAN_JSON:":=",%" set /a count = 0 for %%I in (%RMAN_JSON%) do ( if !count! == 1 ( if /I NOT %%I == 0 ( echo Request to start backup failed, exiting echo Response from Phoenix Backup Store %RMAN_JSON% exit /b 1 ) else ( echo Request to start backup succeeded ) ) if !count! == 15 ( echo Setting Snapshot Name: %%I set SNAP_NAME=%%~I ) set /a "count+=1" ) set SNAP_NAME=%SNAP_NAME:~,-2% echo Snapshot to be created: %SNAP_NAME% REM set SNAP_NAME="" if %SNAP_NAME% == "" ( echo "Empty Snapshot Name. Exiting." exit /b ) set LOG_FILE_DIR=%complete_mount%\_workspace\RMAN_Logs echo LOG FILE DIR IS := %LOG_FILE_DIR% if not exist %LOG_FILE_DIR% ( mkdir %LOG_FILE_DIR% if !ERRORLEVEL! NEQ 0 ( echo Unable to create directory %LOG_FILE_DIR.. exiting exit /b ) ) set RMAN_LOGFILE=%LOG_FILE_DIR%\rman_inc_backup_%SNAP_NAME%_WIN.log rman log=%RMAN_LOGFILE% @oracle_rman_data_incremental_daily_backup_windows.rman using '%complete_mount%' if !ERRORLEVEL! NEQ 0 ( echo RMAN backup failed. Check RMAN log %RMAN_LOGFILE% for the details exit /b ) echo RMAN backup completed echo Notifying Phoenix to upload RMAN Logs for /F %%I in ('curl -X POST -H "Content-Type: multipart/form-data" -F "file=@%RMAN_LOGFILE%" -F "mountpoint=%complete_mount%" -F "platform=windows" http://%1:9090/druva-phoenix/v1/mounts/%2/uploadlog') do set rman_upload_log_curl_output=%%I echo Response from Phoenix Backup Store for upload RMAN Log: %rman_upload_log_curl_output% echo Calling End Backup for /F %%I in ('curl -X PUT http://%1:9090/druva-phoenix/v1/mounts/%2/backup') do set curl_output2=%%I echo Response from Phoenix Backup Store : %curl_output2% :EOF exit /b

oracle_rman_data_incremental_daily_backup_windows.rman

connect target / set echo on; configure backup optimization on; configure controlfile autobackup on; configure device type disk parallelism 1 BACKUP TYPE TO COPY; configure datafile backup copies for device type disk to 1; configure archivelog backup copies for device type disk to 1; configure channel device type disk format '&1\full\full_bk_datafile_%U.rbk'; configure controlfile autobackup format for device type disk to '&1\full\full_bk_controlfile_%F'; run { backup incremental level 1 for recover of copy with tag 'phoenix_oracle_backup' database; backup format '&1\full\inc_daily_bk_Archivelog_%d_%s_%t' archivelog all not backed up; #Force is to ignore I/O errors delete noprompt obsolete device type disk; delete force NOPROMPT expired copy; delete force NOPROMPT expired backup; crosscheck backup; crosscheck copy; } configure backup optimization clear; configure controlfile autobackup clear; exit

Template scripts for Phoenix Backup Store with version 4.9.0 or earlier


❗ Important


​Druva requires you to use the following template scripts for Phoenix Backup Store with version 4.9.0 or earlier.


oracle_rman_backup.bat

echo off if not "%~3"=="" if "%~4"=="" goto START echo Usage : .\oracle_rman_backup.bat <logfiledir> <backup_store_ip> <mount_name> echo Note : Mount name can be any string. It is recommended that the mount name must be same as the name of the database for more clarity. echo Example : .\oracle_rman_backup.bat logdir 192.0.2.1 testmount echo logfiledir : Directory for RMAN log file echo backup_store_ip : IP of backup store echo mount_name : backup mount name as in CPortal goto EOF :START setlocal enableDelayedExpansion enableextensions if not exist %1 ( mkdir %1 if !ERRORLEVEL! NEQ 0 ( echo Unable to create directory %1.. exiting exit /b ) ) for /F "tokens=*" %%I in ('curl -X GET http://%2:9090/druva-phoenix/v1/mounts/%3/backup') do set validate_curl_output=%%I set VALIDATE_JSON=%validate_curl_output% set "VALIDATE_JSON=%VALIDATE_JSON:~1,-1%" set "VALIDATE_JSON=%VALIDATE_JSON:":=",%" set /a vcount = 0 REM Check for validate response for %%I in (%VALIDATE_JSON%) do ( if !vcount! == 1 ( if /I NOT %%I == 0 ( echo Request to validate backup failed, exiting echo Response from Phoenix Backup Store %VALIDATE_JSON% exit /b 1 ) else ( echo Request to validate backup succeeded ) ) REM is_max_snapshot_reached if !vcount! == 6 ( if %%~I == "true" ( echo Request to validate backup failed, exiting echo Response from Phoenix Backup Store %VALIDATE_JSON% exit /b 1 ) ) set /a "vcount+=1" ) for /F %%I in ('curl -X POST http://%2:9090/druva-phoenix/v1/mounts/%3/backup') do set curl_output=%%I set JSON=%curl_output% set "JSON=%JSON:~1,-1%" set "JSON=%JSON:":=",%" set /a count = 0 for %%I in (%JSON%) do ( if !count! == 1 ( if /I NOT %%I == 0 ( echo Request to start backup failed, exiting echo Response from Phoenix Backup Store %JSON% exit /b 1 ) else ( echo Request to start backup succeeded ) ) if !count! == 6 ( set mount_name=%%~I ) if !count! == 13 ( set mount_path=%%~I ) set /a "count+=1" ) set mount_path=%mount_path:~,-2% set mount_path=!mount_path:/=\! set complete_mount=\\%2%mount_path% echo Mount name %mount_name% echo NFS mount path %complete_mount% if not exist %complete_mount%\full ( echo Creating directory %complete_mount%\full mkdir %complete_mount%\full if !ERRORLEVEL! NEQ 0 ( echo Unable to create directory %complete_mount%\full.. exiting exit /b ) ) FOR /F "tokens=*" %%a in ('date /t') do SET date=%%a set date=!date: =_! set date=!date:/=_! FOR /F "tokens=*" %%a in ('time /t') do SET time=%%a set time=!time: =_! set time=!time::=_! rman log=%1\rman_full_backup.log @rman_backup_windows.rman using '%complete_mount%' if !ERRORLEVEL! NEQ 0 ( move %1\rman_full_backup.log %1\rman_full_backup%date%%time%.log echo RMAN backup failed. Check RMAN log %1\rman_full_backup%date%%time%.log for the details exit /b ) move %1\rman_full_backup.log %1\rman_full_backup%date%%time%.log echo RMAN backup completed echo RMAN log file %1\rman_full_backup%date%%time%.log echo Notifying Phoenix to upload RMAN Logs for /F %%I in ('curl -X POST -H "Content-Type: multipart/form-data" -F "file=@%1\rman_full_backup%date%%time%.log" -F "mountpoint=%complete_mount%" -F "platform=windows" http://%2:9090/druva-phoenix/v1/mounts/%3/uploadlog') do set rman_upload_log_curl_output=%%I echo Response from Phoenix Backup Store for upload RMAN Log: %rman_upload_log_curl_output% for /F %%I in ('curl -X PUT http://%2:9090/druva-phoenix/v1/mounts/%3/backup') do set curl_output2=%%I echo Response from Phoenix Backup Store : %curl_output2% :EOF exit /b

rman_backup_windows.rman

connect target / set echo on; configure backup optimization on; configure controlfile autobackup on; configure device type disk parallelism 1 BACKUP TYPE TO COPY; configure datafile backup copies for device type disk to 1; configure archivelog backup copies for device type disk to 1; configure channel device type disk format '&1\full\full_bk_datafile_%U.rbk'; configure controlfile autobackup format for device type disk to '&1\full\full_bk_controlfile_%F'; run { backup incremental level 1 for recover of copy with tag 'phoenix_oracle_backup' database; backup format '&1\full\full_bk_Archivelog_%d_%s_%t' archivelog all not backed up; recover copy of database with tag 'phoenix_oracle_backup'; #Force is to ignore I/O errors delete noprompt obsolete device type disk; delete force NOPROMPT expired copy; delete force NOPROMPT expired backup; crosscheck backup; crosscheck copy; } configure backup optimization clear; configure controlfile autobackup clear; exit

Did this answer your question?