Just copy the text below to a text file an save it with a .vbs extension. The file can be named anything descriptive as longs as it has the .vbs extension. There is text within the script describing a sample batch file which can be used with Windows Task Scheduler to schedule this script to run.
Option Explicit
'' BESR-Job.vbs
''
''
'' Description: The user defines an array of external drives to be used for storing BESR Images
'' The script will then determine if any of the external drives are attached.
'' If not attached, the script and imaging process are aborted.
'' The first external drive found will be the drive used. The search process will cease.
''
'' A One-Time imaging job will be created and the images will be stored in a folder
'' reflecting the current date i.e. X:\23-Jul-09
'' The image job will always be a full backup -- no incrementals.
'' The job will not be reflected as a recurring job in the BESR task Scheduler.
'' BESR will be able to manage the images created in the Manage Backup Destinmation interface.
'' Deleting aged images will be the user's responsibility
''
'' Executing: The script can be invoked from the command line i.e cscript.exe BESR-Job.vbs
'' Invoking command from a batch file will allow the script to be used with
'' Windows Task Scheduler for repeated use.
'' Sample batch file contents: Cscript.exe "D:\Scripted-Tasks\BESR-Job.vbs"
Dim oFSO, oV2iAuto, oWSHShell
Dim aUSBDrives, oDriveLetter
Dim sDriveLetter, sDestDriveLetter, sPath
Dim sDay, sWeekdayName, sMonth, sYear, sDateTime
Dim sServerName, sVolumesArray
Dim oVolume, oTempVolume
Dim oVolume_C, oVolume_D
Dim oNetLocation_C_Image
Dim oNetLocation_D_Image
Dim oPREIMAGE, oPOSTSNAP, oPOSTIMAGE
Dim oImageJob
'' Construct array of USB drives used to store BESR images
'' Edit to reflect drive letters used in your environment
'' Note: No colons or backslashes used in Array
'' Sample for array of five drives
'' aUSBDrives = Array("V","W","X","Y","Z")
'' Define array of external drives on line below
aUSBDrives = Array("X")
' Iterate through the array and determine which USB drive
' if any, is attached to the server
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
For Each oDriveLetter In aUSBDrives
sDriveLetter = oDriveLetter
Select Case oFSO.DriveExists(sDriveLetter)
Case True
sDestDriveLetter = sDriveLetter
Exit For
Case False
WScript.Sleep 0
Case Else
WScript.Echo "Drive status cannot be determined" & VbCrLf
End Select
Next
' Were any of the USB drives actually attached?
If sDestDriveLetter = "" Then
WScript.Echo "None of the designated USB drives were attached to the server."
WScript.Echo "Aborting imaging process." & VbCrLf
subCleanup
Else
WScript.Sleep 0
WScript.Echo "Drive letter " & sDestDriveLetter & " is attached."
WScript.Echo "Proceeding............." & VbCrLf
End If
'' Construct destination folder path then create folder.
'' The folder name will be based on the current Date
'' and in DD-MMM-YY format
sDateTime = Now
sDay = DatePart("d",sDateTime)
sWeekdayName = WeekdayName(DatePart("w",sDateTime))
WScript.Echo "Day of the month is: " & sDay & VbCrLf
WScript.Echo "Weekday name is: " & sWeekdayName & VbCrLf
'Extract only first three letters of the month
sMonth = Left(MonthName(DatePart("m",sDateTime)),3)
WScript.Echo "The month is: " & sMonth & VbCrLf
'Extract only last two digits of the Year
sYear = Right(Year(sDateTime),2)
WScript.Echo "The Year is: " & sYear & VbCrLf
sPath = sDestDriveLetter _
& ":\" _
& sDay & "-" _
& sMonth & "-" _
& sYear
WScript.Echo "The path for image storage is: " & sPath &VbCrLf
'Create or recreate folder as needed.
Select Case oFSO.FolderExists(sPath)
Case True
'Destroy folder then recreate it
oFSO.DeleteFolder(sPath)
oFSO.CreateFolder(sPath)
WScript.Echo "Folder destroyed and recreated."
Case False
'Create the folder from new
oFSO.CreateFolder(sPath)
WScript.Echo "Folder created from new"
End Select
'*****************************************************************
'' Imaging Section of Script
'' Determine computer name and set appropriate varaible
Set oWSHShell = WScript.CreateObject( "WScript.Shell" )
sServerName = oWSHShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
WScript.Echo "The server name is: " & sServerName & VbCrLf
'' Create the BESR automation object and connect to the local BESR agent
Set oV2iAuto = CreateObject("Symantec.ProtectorAuto")
Call oV2iAuto.Connect(sServerName)
'
' Find the volumes to image
'
On Error Resume Next
sVolumesArray = ""
WScript.Echo "The array is now populated with: " & sVolumesArray & VbCrLf
For Each oTempVolume in oV2iAuto.Volumes(false)
Select Case oTempVolume.MountPoint
Case "C:\"
Set oVolume_C = oTempVolume
sVolumesArray = "oVolume_C.ID"
WScript.Echo "The current mountpoint is: " & oTempVolume.MountPoint
WScript.Echo "Volume ID for C:\ is: " & oVolume_C.ID
WScript.Echo "The array is now populated with: " & sVolumesArray
WScript.Echo VbCrLf
Case "D:\"
Set oVolume_D = oTempVolume
If sVolumesArray = "oVolume_C.ID,oVolume_D.ID" Then
WScript.Sleep 0
Else
sVolumesArray = sVolumesArray & ",oVolume_D.ID"
End If
WScript.Echo "The current mountpoint is: " & oTempVolume.MountPoint
WScript.Echo "Volume ID for D:\ is: " & oVolume_D.ID
WScript.Echo "The array is now populated with: " & sVolumesArray
WScript.Echo VbCrLf
Case Else
Wscript.Sleep 0
End Select
Next
On Error GoTo 0
'' Define objects for storing volume images and set image file name spec.
Set oNetLocation_C_Image = CreateObject("Symantec.VProRecovery.NetworkLocation")
oNetLocation_C_Image.Path = sPath
oNetLocation_C_Image.FileSpec = sServerName & "_C"
Set oNetLocation_D_Image = CreateObject("Symantec.VProRecovery.NetworkLocation")
oNetLocation_D_Image.Path = sPath
oNetLocation_D_Image.FileSpec = sServerName & "_D"
'' Uncomment for any PreImaging, Post Snapshot or Post Imaging Tasks required
'''''''''''''' Preimaging Tasks ''''''''''''''''''''''''''''''''
' Set oPREIMAGE = CreateObject("Symantec.VProRecovery.CommandFile")
' oPREIMAGE.Timeout = 720
' oPREIMAGE.Name = "PREIMAGE"
' oPREIMAGE.Folder = "D:\Scripted-Tasks\BESR\"
' oPREIMAGE.Filename = "StopSQLServices.bat"
' oPREIMAGE.Validate()
'''''''''''''' Post Sanapshot Tasks ''''''''''''''''''''''''''''''''
' Set oPOSTSNAP = CreateObject("Symantec.VProRecovery.CommandFile")
' oPOSTSNAP.Timeout = 720
' oPOSTSNAP.Name = "POSTSNAP"
' oPOSTSNAP.Folder = "D:\Scripted-Tasks\BESR\"
' oPOSTSNAP.Filename = "Postsnap.bat"
' oPOSTSNAP.Validate()
'''''''''''''' Post Imaging Tasks ''''''''''''''''''''''''''''''''
' Set oPOSTIMAGE = CreateObject("Symantec.VProRecovery.CommandFile")
' oPOSTIMAGE.Timeout = 720
' oPOSTIMAGE.Name = "POSTIMAGE"
' oPOSTIMAGE.Folder = "D:\Scripted-Tasks\BESR\"
' oPOSTIMAGE.Filename = "StartSQLServices.bat"
' oPOSTIMAGE.Validate()
' Create the image job
'
Set oImageJob = CreateObject("Symantec.VProRecovery.ImageJob")
oImageJob.IncrementalSupport = False
oImageJob.DisplayName = sWeekdayName & " Full Backup"
oImageJob.Description = sWeekdayName & "-- Full backup of C: and D: Drives"
'' Uncomment desired image compression level, comment undesired levels
'oImageJob.Compression = oImageJob.Constants.ImageCompressionNone
'oImageJob.Compression = oImageJob.Constants.ImageCompressionLow
oImageJob.Compression = oImageJob.Constants.ImageCompressionMedium
'oImageJob.Compression = oImageJob.Constants.ImageCompressionHigh
oImageJob.Reason = oImageJob.Constants.ImageReasonManual
oImageJob.Volumes = Array(sVolumesArray)
oImageJob.Quota = 0
oImageJob.Task = Nothing
'' Uncomment if running any Pre, or post tasks
'oImageJob.CommandFile("PREIMAGE") = oPREIMAGE
'oImageJob.CommandFile("POSTSNAP") = oPOSTSNAP
'oImageJob.CommandFile("POSTIMAGE") = oPOSTIMAGE
oImageJob.Location(oVolume_C.ID) = oNetLocation_C_Image
oImageJob.Location(oVolume_D.ID) = oNetLocation_D_Image
oImageJob.RunOnce = True
' Add the image job to jobs list
Call oV2iAuto.AddImageJob(oImageJob)
'Execute the image job now!!!!
Call oV2iAuto.DoImageJob(oImageJob.ID, oImageJob.Constants.ImageTypeFull)
' ' Run object cleanup subroutine
subCleanup
'' subCleanup
'' Purpose: Cleans up Objects and quits the script
Sub subCleanup
Set oFSO = Nothing
Set oDriveLetter = Nothing
Set oV2iAuto = Nothing
Set oWSHShell = Nothing
Set oVolume = Nothing
Set oTempVolume = Nothing
Set oVolume_C = Nothing
Set oVolume_D = Nothing
Set oVolume = Nothing
Set oNetLocation_C_Image = Nothing
Set oNetLocation_D_Image = Nothing
Set oPREIMAGE = Nothing
Set oPOSTSNAP = Nothing
Set oPOSTIMAGE = Nothing
Set oImageJob = Nothing
WScript.Quit
End Sub