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 hot_backup_full.bat file.
@call C:\oracle\BKC\BACKUPS\scripts\env.cmd
@SET EXECCMD=C:\oracle\BKC\BACKUPS\scripts\hot_backup_full.cmd %1
@SET LOGFILE=C:\oracle\BKC\BACKUPS\scripts\logs\hot_Backup_full.log
@REM ************************* EXECUTION SECTION *************************
move %LOGFILE% %LOGFILE%.bkp_full.txt
@cls
@echo --------------------------------------------------------------------------------
@echo EXECUTING SCRIPT: %0
@echo --------------------------------------------------------------------------------
@echo ------------------- RMAN BACKUP BEGIN %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%
@rem call C:\oracle\BKC\BACKUPS\scripts\envio_mail.bat
@echo ------------------- RMAN 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 hot_backup_full.cmd file.
@REM ********* DOCUMENTATION SECTION **********************
@REM * Backup full
@REM ********* CONFIGURACION SECTION **********************
call %ENVFILE%
@REM ***************** SECCION EJECUCION ********************************
rman target user_db/password@sid catalog user_catalog/password@db_catalog cmdfile=C:\oracle\BKC\BACKUPS\scripts\HOT_BACKUP_FULL_diario.RMA msglog=C:\oracle\BKC\BACKUPS\scripts\logs\rman_BACKUP.log
@echo %ERRORLEVEL%
set RMAN_ERROR=%ERRORLEVEL%
goto :final
:final
@rem exit 0
:end
4- Finally we create hot_backup_full_diario.rma file.
run
{
allocate channel t1 type 'sbt_tape'
parms 'ENV=(TDPO_OPTFILE=C:\Program Files\Tivoli\TSM\AgentOBA\ccrjr\tdpod.opt)';
sql 'alter system archive log current';
backup
incremental level = 0
filesperset 1
tag = 'ccrjr_lv0'
format 'ccrjr_df_dia_%T_%u'
database
keep until time 'sysdate+15' logs;
backup
current controlfile
tag = cf_ccrjr
format 'ccrjr_cf_dia_%T_%u';
crosscheck archivelog all;
backup
filesperset 1
format 'ccrjr_ar_dia_%T_%u'
archivelog all delete input;
release channel t1;
}
Comments