Symantec Backup Exec PowerShell
I was wondering if it is possible to connect using PowerShell to Symantec Backup Exec server, and pull a summary of backup jobs. You might think that Symantec Backup Exec already has many notification options, so why to invest time to do that via PowerShell.
Well, imagine that you have a complex backup cycle and you want to do customized reporting, but you need to get the data first. Also, sometimes you might have many installations of Backup Exec and you want to generate one report. It is always nice to know that you can use PowerShell to query information about your Backup Exec server.
Symantec Backup Exec PowerShell report
This script will connect to Symantec Backup Exec server and using PowerShell, and will collect the following information about the backup jobs:
- Job Name
- Selection Summary
- Start Time
- Elapsed Time
- Job Status
- Media Label
- Total Data Size Bytes
- Job Rate MB Per Minute
The script has two filters:
- Name Like Expression: You can say for example ,give me jobs where the name contains “*OffSite*”
- Time Expression: You can either use:
- Since X Days: like give me all jobs happened since X days.
- From Last Job Run: give me the last job run information for the jobs.
Below is the list of Script Parameters:
Path to store script files like “.\” to indicate current directory or full path like C:\myfiles.
Send Mail after completion. Set to $True to enable. If enabled, -MailFrom, -MailTo, -MailServer are mandatory
Email address to send from.
Email address to send to.
Expression filter to filter on Job names. Example is “*OffSite*” to filter for any job with the word “OffSite” in the job name.
Filter jobs happening in the past X days.This parameter cannot be used with the -FromLastJobRun switch parameter
Switch parameter. When used, the script will bring only the last run job instances. This switch parameter cannot be used with the -Days parameter.
Get BackupExec Jobs and send email with the results
Get-BEJobs.ps1 -ScriptFilesPath .\ -SendMail:$true -MailFrom email@example.com -MailTo firstname.lastname@example.org -MailServer smtp.contoso.com
Get BackupExec Jobs happening in the last 3 days
Get-BEJobs.ps1 -ScriptFilesPath .\ -Days 3
Get BackupExec Jobs with the name containing “*Yearly*”
Get-BEJobs.ps1 -ScriptFilesPath .\ -NameLike "*Yearly*"
Get BackupExec Jobs with the name containing “*Yearly*” and only returning the last job run results
Get-BEJobs.ps1 -ScriptFilesPath .\ -NameLike "*Yearly*" -FromLastJobRun
Get BackupExec Jobs with the name containing “*Yearly*” happening last week
Get-BEJobs.ps1 -ScriptFilesPath .\ -NameLike "*Yearly*" -Days 7
The script will generate three log files:
- Info Log : will help you track what the script is doing.
- Error Log : in case of errors
- Detailed Log : contains detailed information about each job run
The script will also generate a nice HTML table that contains the list of jobs and their information
The script has an option to send results via an email if you choose to configure SMTP settings via one of the script parameters.
The challenge I faced writing this script is querying the Media Label field because this field is obtained from the XML returned by the Get-JobLog.
So if you write Get-Job | Get-JobHistory | GetJobLog
Then you will have XML file with the media label information there. I had to do some string operations to extract the media label information.
The script should be running from within the BackupExec server and it is tested with BackupExec 2014 only.
You can download the script from Microsoft TechNet Gallery.