#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    128
    Rep Power
    4

    Event log backup


    Hi,
    I need a script to do event log backup, system event log only.
    I found this script online but when I run it the system.evt file is much smaller than the file I collect manually.
    Could you guys help me with this?
    Thanks, vl123456

    Code:
    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='System'")
    
    For Each objLogfile in colLogFiles
        objLogFile.BackupEventLog("c:\scripts\" & strBackupName & _
            "_system.evt")
    Next
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    128
    Rep Power
    4
    Any help, ideas on this?
    Thanks, Vl123456
  4. #3
  5. No Profile Picture
    Stumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,409
    Rep Power
    4538
    I don't know, sorry. There should be some documentation on scripting event log backups somewhere in msdn.
    ======
    Doug G
    ======
    It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    128
    Rep Power
    4
    Thank you Doug!
    I found this script and it does what I need.

    Code:
    dtmThisDay = Day(Date)
    dtmThisMonth = Month(Date)
    dtmThisYear = Year(Date)
    strComputer = "."
    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='System'")
    
    For Each objLogfile in colLogFiles
        objLogFile.BackupEventLog("c:\scripts\" & strBackupName & _
            "_system.evt")
    Next
  8. #5
  9. No Profile Picture
    Stumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,409
    Rep Power
    4538
    I'm glad you got a solution!
    ======
    Doug G
    ======
    It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    128
    Rep Power
    4
    Thank you Doug.

IMN logo majestic logo threadwatch logo seochat tools logo