June 2nd, 2012

Weekend Scripter: Managing Symantec Backup Exec 2012 with PowerShell

Doctor Scripto
Scripter

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.

Photo of Mike F Robbins

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.

Blog: http://mikefrobbins.com

Twitter: @mikefrobbins

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:

Get-BETapeDriveDevice |

Submit-BEInventoryJob |

select Name, JobType, Schedule, Storage |

ft –auto

Image of command output

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.

Get-BETapeDriveDevice |

select Name, Media |

ft –auto

Image of command output

Perform a quick erase on the backup tape in each of the tape drives:

Get-BETapeDriveDevice |

Submit-BEEraseMediaJob |

select Name, JobType, Status, Schedule |

ft -auto

Image of command output

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*” |

Start-BEJob |

Out-Null

Image of command output

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

ft -auto

Image of command output

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

Image of command output

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

Start-BEJob |

Out-Null

Image of command output

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 |

ft -auto

Image of command output

Cancel all of the active backup jobs:

Get-BEJob -Status “Active” |

Stop-BEJob |

ft –auto

Image of command output

Eject the backup tape from each of the tape drives:

Get-BETapeDriveDevice |

Submit-BEEjectMediaJob |

Out-Null

Image of command output

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:

Symantec Backup Exec 2012 Adds PowerShell Support!

Want to learn more about the Symantec Backup Exec BEMCLI PowerShell module? Download the Help file:

Backup Exec 2012 Management Command Line Interface (BEMCLI) Documentation

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.

~Mike

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 scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy 

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.