Wednesday, May 18, 2016

Script to zip up logs to date named file

q: How can we run a script weekly/monthly to zip up log files on a windows server, using a batch script and have the file be named the server & today's date?

a: This .bat assumes (1) you have izarc & izarcl installed (2) you have d:\download\ folder (3) your log files are on d:\

REM Final revision
@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
Set myfilename=%COMPUTERNAME%-%mydate%
echo %myfilename%
"c:\Program Files (x86)\IZArc\IZARCC.exe" -m -r -P D:\Download\%myfilename%_logs.zip d:\u_ex*.log -$d:\Download

NOTE: again you might want to include this line at the end to empty the recycle bin:
rd /q /s d:\$RECYCLE.BIN

No comments:

Post a Comment