Using .bat-scripts in "Execute external program" a

If you have information, script, utility, or idea that can be useful for HostMonitor community, you welcome to share information in this forum.
Post Reply
Dubolomov
Posts: 214
Joined: Thu Jun 01, 2006 10:27 am
Location: Russia

Using .bat-scripts in "Execute external program" a

Post by Dubolomov »

This is example of how to use bat-files with macro variables as command line parameters.

I have all log-files of HostMonitor in "C:\Logs\" folder. In "Log setting" option i'm use log format as a text file with "C:\Logs\%yyyymmdd%--log.txt" filename so there are new log files create every night at 0:00am:
C:\Logs\20070216--log.txt
C:\Logs\20070215--log.txt
C:\Logs\20070214--log.txt
C:\Logs\20070213--log.txt
...
I would like to have logs for last week but to be on the safe side i archiving all older logs in "C:\Backup\" folder using winzip. In Scheduler option of HM i created task named "Archive Logs and HM" with Execute external program action that executes daily at 0:10am. Option of this action has script file:
"C:\Program Files\HostMonitor5\Scripts\Archive.bat" %yyyymmdd[-8d]% %yyyymmdd[-1d]% %yyyymmdd% %hhnn%
This is start .bat-file with parameters.

Bat-file has a few commands:
@echo %1 - Date of files for deleting (yyyymmdd[-8d]).
@echo %2 - Yesterday (yyyymmdd[-1d]).
@echo %3 - Today (yyyymmdd).
@echo %4 - Real Time (hhnn).

@if '%1'=='' goto quit
@if '%2'=='' goto quit
@if '%3'=='' goto quit
@if '%4'=='' goto quit

del /Q "C:\Logs\*%1--log.txt" > "C:\Logs\SysLog\Archive--%3_%4.log"
"C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc "C:\BackUp\HostMonitor_Logs_%2__(created_at__%3_%4).zip" "C:\Logs\*%2--log.txt" >> "C:\Logs\SysLog\Archive--%3_%4.log"
"C:\Program Files\HostMonitor5\Utils\WinZIP\Wzzip.exe" -a -ep -whs -p -r -ybc "C:\BackUp\HostMonitor_%3__(created_at__%3_%4).zip" "C:\Program Files\HostMonitor5" >> "C:\Logs\SysLog\Archive--%3_%4.log"

:quit
exit


So in "C:\Backup\" folder i have archive of all log-files and full backup of HostMonitor with it's settings.
It's possible to add in bat-file script commands for copying all archives on any network drive for fully safety of backup. I'm using external service for this.
Post Reply