Script to Archive Log Files

Script to parse and archive log files.

rem **********
rem Parse IIS Log files into SQL and archive the files
rem Author: M@
rem Date: 2007-06-27
rem **********

set logDir=E:LogFilesW3SVCnumbers
set parseDir=%logDir%ParseDir
set archiveDir=%logDir%Archive

rem **********
rem Move all non-locked log files to the parse directory
rem **********

move %logDir%* %parseDir%

rem **********
rem Parse the logs into our SQL database
rem **********

LogParser "SELECT * INTO WebLogs FROM %parseDir%*.log where cs-Uri-Stem like
'/tracking/%%'" -i:IISW3C -o:SQL -server:dbserver -database:weblogs
-driver:"SQL Server" -username:username -password:password -createTable:ON

rem **********
rem Compress all the files from the parse directory to the archive directory
rem **********

for %%c in (%parseDir%*.log) do makecab %%c /L %archiveDir%

rem **********
rem Remove the files we just parsed and compressed
rem **********

del %parseDir%*.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