在系統管理中服務器日誌的重要性無需多言,如何更好的作好日誌備份是一管理員必須的技能,以應用程序爲例,咱們都知道應用程序日誌的路徑c:\windows\system32\config\appevent.evtwindows
咱們能夠利用如下腳本按本身要求備份日誌:服務器
dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Backup)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName='Application'")
Set objNetwork = CreateObject("WScript.Network")
strLocalComputer = objNetwork.ComputerName app
For Each objLogfile in colLogFiles
objLogFile.BackupEventLog("C:\" & strLocalComputer & "_" & strBackupName & _
"_application.evt")
Nextide