Script to backup log files
Hello, I am looking for a script to backup the system, app and security log files to the network with a the computername, time and date stamp on the file If that is successful then clear the log files. I have checked around the internet and have not found what I am looking for. Thanks for the help, Tom
January 26th, 2012 4:17pm

1. You have omitted important information, namely the operating system. 2. There are native tools for backup http://technet.microsoft.com/en-us/library/cc754097(WS.10).aspx 3. Use scripting for event logs. I recommend you to address this specific task in the Powershell forum here: http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/threads Regards Milos
Free Windows Admin Tool Kit Click here and download it now
January 26th, 2012 4:23pm

Hello, this way the security log is safed and cleared and stored where you like, in the example here on the d:\ drive ;The account that runs the scheduled task, needs the user rights assignment: backup files and directorys, logon as a batch job, generate security audits, manage auditing and security log ;Save this file as .vbs strDate = Year(Now) & "-" & Right("0" & Month(Now),2) & "-" & Right("0" & Day(Now),2) & "-" strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate,(Backup,Security)}!\\" & _ strComputer & "\root\cimv2") Set colLogFiles = objWMIService.ExecQuery _ ("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName='Security'") For Each objLogfile in colLogFiles errBackupLog = objLogFile.BackupEventLog("d:\SecurityLog\"& strDate &"security.evt") If errBackupLog <> 0 Then Wscript.Echo "The Security event log could not be backed up." Else objLogFile.ClearEventLog() End If Next Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
January 26th, 2012 4:29pm

Hello, this way the security log is safed and cleared and stored where you like, in the example here on the d:\ drive ;The account that runs the scheduled task, needs the user rights assignment: backup files and directorys, logon as a batch job, generate security audits, manage auditing and security log ;Save this file as .vbs strDate = Year(Now) & "-" & Right("0" & Month(Now),2) & "-" & Right("0" & Day(Now),2) & "-" strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate,(Backup,Security)}!\\" & _ strComputer & "\root\cimv2") Set colLogFiles = objWMIService.ExecQuery _ ("SELECT * FROM Win32_NTEventLogFile WHERE LogFileName='Security'") For Each objLogfile in colLogFiles errBackupLog = objLogFile.BackupEventLog("d:\SecurityLog\"& strDate &"security.evt") If errBackupLog <> 0 Then Wscript.Echo "The Security event log could not be backed up." Else objLogFile.ClearEventLog() End If Next Best regards Meinolf Weber Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
January 27th, 2012 12:24am

The OS is Windows 2003 and Windows 2008 Server.
January 30th, 2012 11:20am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics