Summary: Guest blogger, Mike F. Robbins, shows how to use Windows PowerShell to work with Backup Exec.
Microsoft Scripting Guy, Ed Wilson, is here. Today we have a new guest blogger, Mike F. Robbins. In this blog, Mike illustrates Windows PowerShell techniques for working with Symantec’s Backup Exec product.
Mike F. Robbins is an MCITP | Windows PowerShell enthusiast | IT Pro | senior systems engineer who has worked on Windows Server, Hyper-V, SQL Server, Exchange Server, SharePoint, Active Directory, and EqualLogic storage area networks. He has over eighteen years of professional experience providing enterprise computing solutions for educational, financial, healthcare, and manufacturing customers.
For those of us who use Symantec Backup Exec in our datacenters, there has recently been a revolutionary breakthrough: the 2012 version adds Windows PowerShell support via a BEMCLI PowerShell module.
This blog is not meant to be a deep dive into Windows PowerShell or Backup Exec. I am going to walk you through how to perform some basic Backup Exec tasks with Windows PowerShell to give you an idea about how easy it is to manage without a GUI. You will see me pipe the output of several commands to the Select-Object cmdlet and others to the Out-Null cmdlet to reduce the number of items that are returned or to eliminate the output all together. By default, many of these cmdlets return a lot of items, which makes them output a list instead of a table.
Run an inventory to discover what backup tapes are in the tape drives:
select Name, JobType, Schedule, Storage |
When the inventory completes, use the Get-BETapeDriveDevice cmdlet to retrieve the name of the backup tape in each tape drive. This cmdlet doesn’t return the media (tape) name by default.
select Name, Media |
Perform a quick erase on the backup tape in each of the tape drives:
select Name, JobType, Status, Schedule |
The following command starts both of the overwrite jobs that I’ve defined, which overwrites the backup tape in each tape drive. The Start-BEJob cmdlet doesn’t support wildcard characters, but you can use them with the Get-BEJob cmdlet and then pipe that cmdlet to Start-BEJob.
Get-BEJob -Name “o*” |
Get a list of the backup jobs that failed with a status of error in the past 12 hours:
Get-BEJobHistory -JobStatus Error -FromStartTime (Get-Date).AddHours(-12) |
The Help that is provided with the cmdlets in this module is very thorough. All of the valid values for parameters such as the JobStatus parameter that I used in the previous command are listed in the Help:
help Get-BEJobHistory –Parameter JobStatus
Re-run the backup jobs that failed due to a status of error in the past 12 hours:
Get-BEJob -Name (Get-BEJobHistory -JobStatus Error -FromStartTime (Get-Date).AddHours(-12) |
select -expand name) |
The Get-BEActiveJobDetail cmdlet returns a list of the backup jobs that are currently active (running), but I prefer to use the Get-BEJob cmdlet for this. I’ve included the jobs that have a status of “Ready”, which are waiting for a storage (backup) device to become available. If these backup jobs were being backed up to the tapes drives, the storage column would contain the tape drive name.
Get-BEJob -Status “Active”, “Ready” |
select Storage, Name, JobType, Status |
Cancel all of the active backup jobs:
Get-BEJob -Status “Active” |
Eject the backup tape from each of the tape drives:
If you experience any issues getting the BEMCLI PowerShell module up and running, see the following blog that I wrote about a month ago; it covers a few issues I ran into:
Want to learn more about the Symantec Backup Exec BEMCLI PowerShell module? Download the Help file:
Windows PowerShell is quickly becoming an essential skill for IT Pros and a required product feature for IT vendors. It’s something that can be used to manage almost everything in your datacenter from a backup product (as shown in this blog) to a storage area network.
The script for this blog can be seen and downloaded from the Script Repository.
Thank you, Mike, for sharing your blog and your time. It is cool to see how to use basic Windows PowerShell techniques while working with other products.
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at firstname.lastname@example.org, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy