Pavan DBA's Blog

The DBA Knowledge Store

script for archives backup in windows

Posted by Pavan DBA on March 26, 2012


#################################

PURGING ARCHIVE LOGS

################################

rem ——————————————————————————————–

rem ——————————————————————————————–

rem -*-

rem -*- Description: Purge old archive logs script for Oracle NT database main program

rem -*-

rem -*- Source file: %ora_utl_dir%\purge_arch_logs.bat

rem -*-

rem — This job:

rem — 1. Removes archived logs from %ora_arch_save_dir% directory

rem — 2. copies archived logs from %ora_arch_dir% directory to %ora_arch_save_dir% directory

rem — 3. Removes archived logs older than %older_than_days% days from %ora_arch_dir% directory

rem -*-

rem -*- Author : Diana Farazi

rem -*- Date Written: 04/20/2000

rem -*-

rem -*- Modification log:

rem -*- Mod Ver Date Who Desciption

rem -*- ——- ———- —————— ————————-

rem -*-

rem ——————————————————————————————–

rem ——————————————————————————————–

 

set ora_sid=PRD2

set ORACLE_SID=%ora_sid%

set tns=bp1tulap151_%ora_sid%

set ora_system_id=system/rsdbsite

set ora_log_dir=i:\d002\oracle\%ora_sid%\utillogs\trim

set ora_utl_dir=i:\d002\oracle\%ora_sid%\utilitys\trim

set ora_vbs_dir=i:\d002\oracle\vbs

 

set ora_arch_dir=i:\d802\oracle\%ORACLE_SID%\arch

set ora_arch_save_dir=i:\d802\oracle\%ORACLE_SID%\arch\save

 

set purge_arch_logs_log=%ora_log_dir%\purge_arch_logs.log

set save_purge_arch_logs_log=%ora_log_dir%\save_purge_arch_logs.log

set older_than_days=2

set email=dba_ora_offshore@bp.com

##set email2=dba_ora_onshore@bp.com

set email_message=

set line=—————————————————————————

set star=*

set error_count=0

 

 

echo %line% > %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

now purge_arch_logs START for %tns% database >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

echo This is: %0 script >> %purge_arch_logs_log%

 

echo %star% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . Before Purge

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Before Purge >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . Before Purge – Listing archive logs in %ora_arch_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Before Purge – Listing archive logs in %ora_arch_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

dir %ora_arch_dir%\*.* >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . Before Purge – Listing archive logs in %ora_arch_save_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Before Purge – Listing archive logs in %ora_arch_save_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

dir %ora_arch_save_dir%\*.* >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . Removing archive logs from %ora_arch_save_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Removing archive logs from %ora_arch_save_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

del %ora_arch_save_dir%\arch*.log

 

rem ———————————————————————————————

rem — . . . Copying archive logs from %ora_arch_dir% to %ora_arch_save_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Copying archive logs from %ora_arch_dir% to %ora_arch_save_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

copy %ora_arch_dir%\arch*.* %ora_arch_save_dir%\

 

rem ———————————————————————————————

rem — . . . Removing archive logs from %ora_arch_dir% older than %older_than_days%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . Removing archive logs from %ora_arch_dir% older than %older_than_days% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

cscript.exe %ora_vbs_dir%\cleanupoldfiles.vbs -d %ora_arch_dir% -o %older_than_days% >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . After Purge

rem ———————————————————————————————

echo %star% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo . . . After Purge >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . After Purge – Listing archive logs in %ora_arch_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . After Purge – Listing archive logs in %ora_arch_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

dir %ora_arch_dir%\*.* >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . After Purge – Listing archive logs in %ora_arch_save_dir%

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo . . . After Purge – Listing archive logs in %ora_arch_save_dir% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

dir %ora_arch_save_dir%\*.* >> %purge_arch_logs_log%

 

rem ———————————————————————————————

rem — . . . END Purge

rem ———————————————————————————————

echo %line% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

now purge_arch_logs END for %tns% database >> %purge_arch_logs_log%

echo %star% >> %purge_arch_logs_log%

 

echo %line% >> %purge_arch_logs_log%

echo %line% >> %purge_arch_logs_log%

 

type %purge_arch_logs_log% >> %save_purge_arch_logs_log%

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: