You are on page 1of 3

REM ##################################################################### REM # Name: rman_hot_backup_dsk.

bat REM # REM # Description: REM # REM # Generic Hot backup script that accepts the SID REM # REM # Parameters: Instance Name, backup level REM # REM ##################################################################### REM # REM # Check if SID was Passed if (%1)==() goto USAGE if (%2)==() goto USAGE REM # assign ORACLE_SID to passed SID set ORACLE_SID=%1 REM # Set the hot backup level 0-full 1-incremental set LEVEL=%2 REM # export the page list set PAGE_LIST=email@domain.com REM # assign a date we can use as part of the logfile set DTE=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2% REM # Take the spaces out of the date string so we can use in our file name set DTE=%DTE: =% REM # set the script location REM # Set location of where you will put script set SCRIPTLOC=C:\app\oracle\scripts cd %SCRIPTLOC% REM # Set the Temporary command file that we will write our rman script to set CMDFILE=%SCRIPTLOC%\%ORACLE_SID%_rman_hot_backup_dsk.cmd REM # Remove the temporary file if it exists del /q %CMDFILE% REM REM set set set # Set the logfile directory # Change based on where you want the backup logs to go LOGPATH=W:\ORACLE_BACKUP\logs LOGFILE=%ORACLE_SID%_rman_hot_backup_dsk_%DTE%.log LOG=%LOGPATH%\%LOGFILE%

REM # Set the path of the backup location REM # Change based on disk pach for you disk based backups set BACKLOC=\\VirtualBox\ORA_ITS03P\ORACLE_BACKUP\%ORACLE_SID% REM # Lets set the ORACLE_HOME for the host REM # Set to your actual ORACLE_HOME location set ORACLE_HOME=C:\app\oracle\product\10.2.0\db_1 # Set the rest of the Oracle Environment # based on our ORACLE_HOME set LIBPATH=%ORACLE_HOME%/lib set LD_LIBRARY_PATH=%ORACLE_HOME%/lib set TNS_ADMIN=%ORACLE_HOME%/network/admin

REM #set ORA_NLS10=%ORACLE_HOME%/nls/data REM Set our PATH with the ORACLE_HOME so that we have a good REM clean environment to work with set PATH=%ORACLE_HOME%/bin;%ORACLE_HOME%/OPatch;%PATH% REM # Write Temporary command file for RMAN backup echo # configure retention policy >> %CMDFILE% echo CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS ; >> %CMDFILE% echo # >> %CMDFILE% echo # lets start clean for our hot backup by doing full crosschecks >> %CMDFILE % echo change archivelog all crosscheck ; >> %CMDFILE% echo crosscheck backup of database; >> %CMDFILE% echo crosscheck backup of controlfile; >> %CMDFILE% echo # >> %CMDFILE% echo # delete all expired and obsolete backups >> %CMDFILE% echo allocate channel for maintenance type disk ; >> %CMDFILE% echo delete noprompt expired archivelog all ; >> %CMDFILE% echo delete noprompt expired backup ; >> %CMDFILE% echo delete noprompt obsolete ; >> %CMDFILE% echo # >> %CMDFILE% echo # Configure control file for auto backup >> %CMDFILE% echo configure controlfile autobackup on ; >> %CMDFILE% echo CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%BACKLOC%\ %ORACLE_SID%_controlfile_%%F' ; >> %CMDFILE% echo # >> %CMDFILE% echo # Configure default device type here we use disk and set parallelism to 2 > > %CMDFILE% echo configure default device type to disk ; >> %CMDFILE% echo configure device type disk parallelism 2 ; >> %CMDFILE% echo # >> %CMDFILE% echo # Must format the default channel for the device type disk >> %CMDFILE% echo # other wise tmp area in creating pieces will be done in >> %CMDFILE% echo # the $ORACLE_HOME/dbs directory >> %CMDFILE% echo CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT = '%BACKLOC%\%ORACLE_SID%_hot_%%U ' ; >> %CMDFILE% echo # >> %CMDFILE% echo # Configure our retention policy for this database >> %CMDFILE% echo configure retention policy to recovery window of 14 days ; >> %CMDFILE% echo # >> %CMDFILE% echo # Let configure our channels for our backup >> %CMDFILE% echo # Channel 1 disk and we indicate where it goes not taking the default >> %C MDFILE% echo configure channel 1 device type disk MAXPIECESIZE = 4G format '%BACKLOC%\%O RACLE_SID%_hot_%%U' ; >> %CMDFILE% echo # Channel 2 disk and we indicate where it goes not taking the default >> %C MDFILE% echo configure channel 2 device type disk MAXPIECESIZE = 4G format '%BACKLOC%\%O RACLE_SID%_hot_%%U' ; >> %CMDFILE% echo # >> %CMDFILE% echo # Backup our database with compression on >> %CMDFILE% echo backup as compressed backupset incremental level %LEVEL% tag hot_%LEVEL%_%D TE% DATABASE ; >> %CMDFILE% echo # >> %CMDFILE% echo # Backup our archive log files that have not been backed up >> %CMDFILE% echo backup as compressed backupset format '%BACKLOC%\%ORACLE_SID%_Archive_%%d_% %s_%%p_%%t' archivelog all not backed up 1 times ; >> %CMDFILE% echo # >> %CMDFILE% echo # Backup Control file for standby in case needed >> %CMDFILE%

echo echo echo echo

backup current controlfile for standby ; >> %CMDFILE% # >> %CMDFILE% # let put a controlfile to trace >> %CMDFILE% sql 'ALTER DATABASE BACKUP CONTROLFILE TO TRACE' ; >> %CMDFILE%

REM # Run the RMAN backup without using the recovery catalog %ORACLE_HOME%\bin\rman target=/ nocatalog cmdfile=%CMDFILE% msglog=%LOG% REM # Remove our temporary command file del /q %CMDFILE% REM # Mail Archive backup log REM # This relies on the free bmail utility bmail -date -m %LOG% -f email@domainl.com -s <smtpserver> -t %PAGE_LIST% -a "HOT Backup results" REM # Goto end of script as we are done goto END :USAGE echo "Must Pass ORACLE_SID and hot backup level as parameters." goto END :END

You might also like