Used Tape Report

Everything about backing up to tape

Used Tape Report

Veeam Logoby squirtleuk » Fri Jun 19, 2015 11:14 am

Guys,

I have tried to write a ps script that will list and email the tapes used each day, I thought to search using the media pool date as a reference. But I am getting no results, below is what I have come up with:

Code: Select all
asnp VeeamPSSnapin

$date = (get-date).ToShortDateString()

#SMTP server name
$smtpServer = "smtp.weatherbys.local"

#Creating a Mail object
$msg = new-object Net.Mail.MailMessage

#Creating SMTP server object
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

#Email structure
$msg.From = "grp-man-bkp01@weatherbys.co.uk"
$msg.ReplyTo = "grp-man-bkp01@weatherbys.co.uk"
$msg.To.Add("abailey@weatherbys.local")
$msg.subject = "Wellingbourgh Veeam Backup Server - Tapes to request back from Iron Mountain"
$msg.body = Get-VBRTapemedium | where {$_.Mediaset -contains '*$date*'} | select Name | Format-Table -Property Name | out-string

#Sending email
$smtp.Send($msg)


Please let me know your thoughts, and any suggestions to achieve my goal.

Thanks in advance.

Alan B.
squirtleuk
Novice
 
Posts: 7
Liked: never
Joined: Tue Jun 09, 2015 1:46 pm
Full Name: Alan Bailey

Re: Used Tape Report

Veeam Logoby v.Eremin » Fri Jun 19, 2015 11:56 am

What if you try to query mediaset name a bit differently?

Code: Select all
Get-VBRTapeMedium | where {$_.mediaset.name -like "*$date*"}


Also, make sure that date present in media set name is written in the same format as variable $date is.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Used Tape Report

Veeam Logoby squirtleuk » Tue Jun 23, 2015 11:47 am

Thanks this works very well. I would like to add to this command the ability to only include tape that are still in the library (i.e. have the script run twice a day, and the script should ignore any tapes already removed after the script has ran the first time). I have come up with this command:

Code: Select all

asnp VeeamPSSnapin

$date = (get-date).ToShortDateString()

#SMTP server name
$smtpServer = "smtp.weatherbys.local"

#Creating a Mail object
$msg = new-object Net.Mail.MailMessage

#Creating SMTP server object
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

#Email structure
$msg.From = "grp-man-bkp01@weatherbys.co.uk"
$msg.ReplyTo = "grp-man-bkp01@weatherbys.co.uk"
$msg.To.Add("itoperationsteam@weatherbys.local")

$msg.subject = "Wellingbourgh Veeam Backup Server - Tapes to request back from Iron Mountain"

$line1 = Get-VBRTapemedium | where ({$_.Mediaset.name -like "*$date*"} -and {$_.Location -like "*Slot*"}) | select Name | Format-Table -Property Name | out-string
$line2 = "Remove these tapes from the Veeam library and send offsite with the Iron Mountain Courier."

$msg.body = "$line1`n`n$line2"

#Sending email
$smtp.Send($msg)



The "{S_.Location -line "Slot"} works on it own to list tapes in the library, but with the "{S_mediaset.name -like "*$date*"} the result is no tapes listed.

Any advice.
squirtleuk
Novice
 
Posts: 7
Liked: never
Joined: Tue Jun 09, 2015 1:46 pm
Full Name: Alan Bailey

Re: Used Tape Report

Veeam Logoby v.Eremin » Tue Jun 23, 2015 12:02 pm

Can't see any issue with code itself. Just for testing purpose can you split filtering into two steps and see whether it helps:

Code: Select all
$CurrentTapes = Get-VBRTapemedium | where {$_.Mediaset.name -like "*$date*"}
$CurrentTapesInSlot = $CurrentTapes | where {$_.location -like "Slot"}


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Used Tape Report

Veeam Logoby Shestakov » Tue Jun 23, 2015 3:12 pm 1 person likes this post

Alan, we are also working on the corresponding report for Veeam One, to deliver our customers from the Powershell.
If you have any recommendations on the info to be shown in the report, please let me know. Thanks!
Shestakov
Veeam Software
 
Posts: 4856
Liked: 395 times
Joined: Wed May 21, 2014 11:03 am
Location: Saint Petersburg
Full Name: Nikita Shestakov

Re: Used Tape Report

Veeam Logoby jacob.estrin » Wed Jun 24, 2015 5:30 am 1 person likes this post

Hi,

I had the same sort of requirement where I needed to list all the tapes that needed to be ejected from our tape loader. I thought it would be worthwhile to post this and found that it is very similar to your script (which I think it is really good by the way). I did put my response in an html format which works well for our guys, however is not required.

My powershell script is:

Code: Select all
# Written by Jacob Estrin on 24/06/2015

#Add Veeam Snap In
Add-PSSnapin -Name VeeamPSSnapIn

#Mail Server Variables
$smtpServer = "192.168.0.1"
$smtpFrom = "veeam@helloworld.com.au"
$smtpTo = "helpdesk@helloworld.com.au"
$messageSubject = "Veeam Tape Ejection Report"

#Message Variables
$message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto
$message.Subject = $messageSubject
$message.IsBodyHTML = $true

#Veeam Tape Variables
$tapecount = $(Get-VBRTapeMedium | Where-Object {$_.IsFree -eq $true -and $_.name -NotLike "CLN*" } |select Name |Sort-Object Name | measure).count
$tapes = Get-VBRTapeMedium | Where-Object {$_.LastWriteTime -ne $null -and $_.Location -like "slot"} |select Name,LastWriteTime |Sort-Object Name | ConvertTo-Html -Head $Header

#Message Body
$Header = @"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 10px;border-style: solid;border-color: black;background-color: #6495ED;}
TD {border-width: 1px;padding: 10px;border-style: solid;border-color: black;}
</style>
"@
$bodyline1= "<p>Please eject the following tapes from the tape loader and replace them with fresh tapes <br><br></p>"
$bodyline2= "<p><br><br>There are currently $tapecount free tapes left in the tape loader. <br><br></p>"
$bodyline3= "<p><br><br>If there are less than 10 fresh tapes available, please order additional tapes. <br><br></p>"
$message.Body = $bodyline1 + $tapes + $bodyline2 + $bodyline3

#Send the Message
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)
jacob.estrin
Novice
 
Posts: 9
Liked: 1 time
Joined: Fri Dec 19, 2014 2:11 am
Full Name: Jacob Estrin


Return to Tape



Who is online

Users browsing this forum: No registered users and 7 guests