SQL Maintenance Plan – Cleanup and backup Event Logs and SQL Trace files

You setup a *.cmd file with the script below which will create CAB files of *.trc and *.evtx files and delete the existing, then move the files to another drive.

@echo **1st step is for DB Audit Logs **

for /R <source path> %%x in (*.trc) DO makecab %%x %%x.cab && Del %%x

@echo **2nd step is for Event Logs **

for /R %Systemroot%\System32\winevt\logs %%x in (*.evtx) DO makecab %%x .cab && Del %%x

Advertisements