Solved

How do modify this script to backup something other than the applications event log?

Posted on 2012-03-21
4
517 Views
Last Modified: 2012-08-14
I have the code below that backs up the applications event log, but instead of the applications event log I need it to back up a particular log file in the applications and services log (applications and service > softwarecompanyA).

How do I modify the code below to do it?

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'")

For Each objLogfile in colLogFiles
    objLogFile.BackupEventLog("c:\scripts\" & strBackupName & _
        "_application.evt")
Next
0
Comment
Question by:Kevin Smith
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
prashanthd earned 500 total points
ID: 37751184
Try following

Modify LogFile="Application" to the event log name you want to take backup example
LogFile="System"

dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay
LogFile="Application"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Backup)}!\\" & _
        strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile where LogFileName='"& logfile &"'")

For Each objLogfile in colLogFiles
    objLogFile.BackupEventLog("c:\scripts\" & strBackupName & _
        "_"&logfile&".evt")
Next

Open in new window

0
 
LVL 12

Expert Comment

by:prashanthd
ID: 37751190
hmmm...Can you be more specific and give an example?
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 37755255
Hi, I'm not that familiar with the new eventing, but have a look at the discussion here:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_26696817.html

Basically, it looks like the wevtutil.exe command is your utility of choice, but you could also try Powershell.  VBScript doesn't seem capable of querying these new event logs.

Rob.
0
 

Author Closing Comment

by:Kevin Smith
ID: 37778741
perfect, thanks :)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scenario:  You do full backups to a internal hard drive in either product (SBS or Server 2008).  All goes well for a very long time.  One day, backups begin to fail with a message that the disk is full.  Your disk contains many, many more backups th…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question