RMAN archive log backup in Windows



This is an example for Oracle archive logs backup only on Windows using RMAN and a catalog database.




1- We create an env.cmd file in order to set all the environtment variables


@REM ----------------------------------------------------------
@REM
@REM    Check ORACLE_HOME and ORACLE_SID
@REM
@REM ----------------------------------------------------------

SET DB=ccrjr
SET DBDIR=ccrjr
SET PATH=C:\oracle\ora92\bin\;%PATH%
SET ORACLE_HOME=C:\oracle\ora92\
SET ORACLE_SID=%DB%
SET SCRIPTS=C:\oracle\BKC\BACKUPS\scripts



2- We create a archivelog_backup.bat file.


@REM ***********************   DOCUMENTATION SECTION ***********************
@REM
@REM
@REM ARCHIVE LOG SCRIPT.
@REM
@REM
@REM ***********************   CONFIGURACION SECTION ***********************


@call        C:\oracle\BKC\BACKUPS\scripts\env.cmd

@SET EXECCMD=C:\oracle\BKC\BACKUPS\scripts\archivelog_backup.cmd %1
@SET LOGFILE=C:\oracle\BKC\BACKUPS\scripts\logs\archivelog_backup.log

@REM *************************   EXECUTION SECTION *************************
move %LOGFILE% %LOGFILE%.bkp_full.txt

@cls
@echo --------------------------------------------------------------------------------
@echo EXECUTING SCRIPT: %0
@echo --------------------------------------------------------------------------------

@echo ------------------- BACKUP Archivelog RMAN %DB% --------------------- >> %LOGFILE%
@echo --------------------------------------------------------------------- >> %LOGFILE%

call C:\oracle\BKC\BACKUPS\scripts\logtime.cmd %LOGFILE%

call %EXECCMD%     >> %LOGFILE%

call C:\oracle\BKC\BACKUPS\scripts\logtime.cmd %LOGFILE%


@echo ------------------- Archivelog BACKUP END %DB% ---------------------- >> %LOGFILE%
@echo --------------------------------------------------------------------- >> %LOGFILE%


@echo  %RMAN_ERROR%
set ERROR_MIO=%RMAN_ERROR%
@echo %ERROR_MIO% >> %LOGFILE%
exit /B %ERROR_MIO%





3- We create a archivelog_backup.cmd file.


@REM ********* DOCUMENTATION SECTION **********************

@REM *    Archivelogs backup

@REM ********* CONFIGURACION SECTION **********************


call %ENVFILE%


@REM ***************** EXECUTION SECTION ********************************

rman  target userdb/password@sid  catalog user_catalog/user_password_catalogo@catalog_database   cmdfile=C:\oracle\BKC\BACKUPS\scripts\archivelog_backup.RMA  msglog=C:\oracle\BKC\BACKUPS\scripts\logs\rman_archivelog.log


@echo %ERRORLEVEL%
set ERROR_DE_RMAN=%ERRORLEVEL%



4- Finally we create archivelog_backup.rma file.


run
{
allocate channel  t1 type 'sbt_tape'
parms 'ENV=(TDPO_OPTFILE=C:\Program Files\Tivoli\TSM\AgentOBA\ccrjr\tdpod.opt)';

crosscheck archivelog all;

    sql "select sysdate from dual";   
    sql "alter system archive log current";
    backup
    current controlfile
    tag = cf_ccrjr
    format 'ccrjr_cf_dia_%T_%u';

backup
filesperset 1
format 'ccrjr_ar_dia_%T_%u'
archivelog all delete input;

release channel t1;

}







Comments