Moving Media with PowerShell and Backup Exec 2012

Last week I blew away my old backup server which was running Backup Exec 2010 R3, installed some new disk and installed Backup Exec 2012, everything went well as expected, but I noticed that the tapes weren’t overwriting each night and waiting for manual confirmation.

Upon further investigation, i found that when Backup Exec runs its inventory it moves the new tape into “Backup Exec and Windows NT Backup Media” which has the wonderful values “Keep indefinitely” and “No append”.

Of course, my first thought is, how can I use automate moving it to the “Scratch Media” set. My second? What if it doesn’t put it into “Backup Exec and Windows NT Backup Media” and puts it somewhere else instead.

Luckily PowerShell is the answer to both of those questions, and even better, you can do it in a 1 liner.

The command breaks down into 3 parts, first we need to get all online media in the tape library:

Get-BEMedia

Next we need to filter the media that we don’t want to move into “Scratch Media”, this might be cleaning tapes or additional tapes that might be in the left in the library. I used $_.MediaSet -ne “Cleaning Media” to filter out any tapes in the “Cleaning Media” media set,  $_.MediaSet -ne “Keep Data for 4 Weeks” to filter out anything in the “Keep Data for 4 Weeks” media set as that is where all tapes are moved to after a backup has been completed. Finally I only want online media (media currently in the library or drive) to be moved, for that I used $_.MediaVault -eq “Online Tape/Disk Cartridge Media”:

Where-Object {$_.MediaSet -ne "Cleaning Media" -and $_.MediaSet -ne 
"Keep Data for 4 Weeks" -and $_.MediaVault -eq "Online Tape/Disk Cartridge Media"}

Lastly we need to move the media that we have selected to the required media set

Move-BEMediaToMediaSet -MediaSet "Scratch Media"

When you put it all together, the script/ 1 liner looks like this:

Get-BEMedia | Where-Object {$_.MediaSet -ne "Cleaning Media" -and $_.MediaSet -ne 
"Keep Data for 4 Weeks" -and $_.MediaVault -eq "Online Tape/Disk Cartridge Media"} |
 Move-BEMediaToMediaSet -MediaSet "Scratch Media"

Set it up on a schedule sometime after the inventory completes, but before your tape backup starts and you won’t need to worry about it not being written to and screwing up your daily backup schedule.

 

Advertisements

About Phill McSherry
Phill McSherry has been working in the Australian IT industry for over 20 years and is the technical manager and solutions architect for managed services provider Titan Solutions - www.titansolutions.com.au

2 Responses to Moving Media with PowerShell and Backup Exec 2012

  1. Thanks for the Powershell writeup. This has been a popular topic for BE customers.

  2. Thanks for reading Sean, its great to get feedback from so many Backup Exec guys

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: