Veeam Report
I was unhappy with the automatic notifications given out by Veeam so I made my own.
I used the Exchange Health Check Power Shell as a guide and here's mine.
Basically this Power Shell runs through the Veeam sessions in the last 24hours and reports on the statuses of each vm within that session, I pull out the time for each vm to backup (Duration) and the amount of Restore Points each VM has.
One thing to note is that if you rename a job in Veeam this does not change the name of the session. I had to add some code to work around a renamed job as I was getting no information for the Restore Points. I left this out of the posting as this was particular to my environment and may not be in yours.
Here's a mock up of what you can expect to see...
Here the Veeam job, Contoso Infra has eight VMs and the job, Contoso Services has 3.
I've scheduled this to run each night. Remember this is set to only bring back the last 24 hours and be careful if you increase this as you will get multiple sessions reporting.
Enjoy.
I used the Exchange Health Check Power Shell as a guide and here's mine.
Basically this Power Shell runs through the Veeam sessions in the last 24hours and reports on the statuses of each vm within that session, I pull out the time for each vm to backup (Duration) and the amount of Restore Points each VM has.
One thing to note is that if you rename a job in Veeam this does not change the name of the session. I had to add some code to work around a renamed job as I was getting no information for the Restore Points. I left this out of the posting as this was particular to my environment and may not be in yours.
Here's a mock up of what you can expect to see...
Here the Veeam job, Contoso Infra has eight VMs and the job, Contoso Services has 3.
Veeam 24hr Backup Report - 2014/10/27
|
Contoso Infra
|
|
Contoso Services
|
|
I've scheduled this to run each night. Remember this is set to only bring back the last 24 hours and be careful if you increase this as you will get multiple sessions reporting.
Enjoy.
---------------------------------------------------------------------------------------------------
# Veeam Powershell Job Status Report
# Allen Kong 24-10-2014 v1.00
# load in snap in
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
# Load in config file
# GroupName, Server
Function writeHtmlHeader{
param($fileName)
$date = ( Get-Date ).ToString('yyyy/MM/dd')
Add-Content $fileName "<html>"
Add-Content $fileName "<head>"
Add-Content $fileName "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
Add-Content $fileName '<title>Veeam Backup Report</title>'
Add-Content $fileName '<STYLE TYPE="text/css">'
Add-Content $fileName "<!--"
Add-Content $fileName "td {"
Add-Content $fileName "font-family: Tahoma;"
Add-Content $fileName "font-size: 11px;"
Add-Content $fileName "border-top: 1px solid #999999;"
Add-Content $fileName "border-right: 1px solid #999999;"
Add-Content $fileName "border-bottom: 1px solid #999999;"
Add-Content $fileName "border-left: 1px solid #999999;"
Add-Content $fileName "padding-top: 0px;"
Add-Content $fileName "padding-right: 0px;"
Add-Content $fileName "padding-bottom: 0px;"
Add-Content $fileName "padding-left: 0px;"
Add-Content $fileName "}"
Add-Content $fileName "body {"
Add-Content $fileName "margin-left: 5px;"
Add-Content $fileName "margin-top: 5px;"
Add-Content $fileName "margin-right: 0px;"
Add-Content $fileName "margin-bottom: 10px;"
Add-Content $fileName ""
Add-Content $fileName "table {"
Add-Content $fileName "border: thin solid #000000;"
Add-Content $fileName "}"
Add-Content $fileName "-->"
Add-Content $fileName "</style>"
Add-Content $fileName "</head>"
Add-Content $fileName "<body>"
Add-Content $fileName "<table width='100%'>"
Add-Content $fileName "<tr bgcolor='#CCCCCC'>"
Add-Content $fileName "<td colspan='7' height='25' align='center'>"
Add-Content $fileName "<font face='tahoma' color='#003399' size='3'><strong>Veeam 24hr Backup Report - $date</strong></font>"
Add-Content $fileName "</td>"
Add-Content $fileName "</tr>"
Add-Content $fileName "</table>"
}
Function writeGroupTableHeader{
param($fileName, $groupName)
Add-Content $fileName "<table width='100%'><tbody>"
Add-Content $fileName "<tr bgcolor=#CCCCCC>"
Add-Content $fileName "<td width='30%' align='center'><font size='3' face='tahoma' color='#003399'><strong>$groupName</strong></font></td>"
Add-Content $fileName "<td align='center'>"
}
Function writeGroupTableFooter{
param($fileName)
Add-Content $fileName "</td>"
Add-Content $fileName "</tr>"
Add-Content $fileName "</table>"
}
Function writeServerTableHeader{
param($fileName)
Add-Content $fileName "<table width='100%'><tbody>"
Add-Content $fileName "<tr bgcolor=#CCCCCC>"
Add-Content $fileName "<td width='25%' align='center'><font size='2'face='tahoma' color='#003399'><strong>Server Name</strong></font></td>"
Add-Content $fileName "<td width='25%' align='center'><font size='2'face='tahoma' color='#003399'><strong>Status</strong></font></td>"
Add-Content $fileName "<td width='25%' align='center'><font size='2'face='tahoma' color='#003399'><strong>Duration</strong></font></td>"
Add-Content $fileName "<td width='25%' align='center'><font size='2'face='tahoma' color='#003399'><strong>Restore Points</strong></font></td>"
Add-Content $fileName "</tr>"
}
Function writeServerTableData{
param($fileName, $Name, $Status, $Hours, $Minutes, $Seconds, $Count)
$Time = "" + $Hours +":"+ $Minutes +":"+ $Seconds
Add-Content $fileName "<tr bgcolor=#DDDDDD>"
Add-Content $fileName "<td align='center'>$Name</td>"
Add-Content $fileName "<td align='center'>$Status</td>"
Add-Content $fileName "<td align='center'>$Time</td>"
Add-Content $fileName "<td align='center'>$Count</td>"
Add-Content $fileName "</tr>"
}
Function writeServerTableFooter{
param($fileName)
Add-Content $fileName "</table>"
}
Function getData{
param($fileName)
$vbrSessions = Get-VBRBackupSession | ? {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addhours(-24)} | Sort-Object JobName
foreach($session in $vbrSessions){
WriteGroupTableHeader $filename $session.Name
WriteServerTableHeader $filename
$vbrRestorePoints = Get-VBRRestorePoint -backup $session.Name
foreach($vm in $session.gettasksessions()){
$Name = $vm.Name
$Status = $vm.Status
$Duration = $vm.progress.StopTime - $vm.progress.StartTime
$Hours = $Duration.Hours
$Minutes = $Duration.Minutes
$Seconds = $Duration.Seconds
$Count = 0
$Count = ($vbrRestorePoints | ? {$_.Name -match $Name} | Measure-Object).Count
writeServerTableData $fileName $Name $Status $Hours $Minutes $Seconds $Count
}
WriteServerTableFooter $filename
WriteGroupTableFooter $filename
}
}
Function sendEmail{
param($from,$to,$subject,$smtphost,$htmlFileName)
$body = Get-Content $htmlFileName
$smtp= New-Object System.Net.Mail.SmtpClient $smtphost
$msg = New-Object System.Net.Mail.MailMessage $from, $to, $subject, $body
$msg.isBodyhtml = $true
$smtp.send($msg)
}
$filename = "C:\Scripts\VeeamReport.htm"
# Remove the "old" report
Remove-Item $filename -ErrorAction SilentlyContinue
# Create the HTML file
WriteHTMLHeader $filename
# Complete the HTML file
getData $filename
# Setup the email
$subject = "Veeam Backup Report : " + ( Get-Date ).ToString('yyyy/MM/dd')
# Send the Email report
sendEmail veeam@contoso.com allen.kong@contoso.com $subject 10.20.30.40 $fileName
# Veeam Powershell Job Status Report
# Allen Kong 24-10-2014 v1.00
# load in snap in
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
# Load in config file
# GroupName, Server
Function writeHtmlHeader{
param($fileName)
$date = ( Get-Date ).ToString('yyyy/MM/dd')
Add-Content $fileName "<html>"
Add-Content $fileName "<head>"
Add-Content $fileName "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
Add-Content $fileName '<title>Veeam Backup Report</title>'
Add-Content $fileName '<STYLE TYPE="text/css">'
Add-Content $fileName "<!--"
Add-Content $fileName "td {"
Add-Content $fileName "font-family: Tahoma;"
Add-Content $fileName "font-size: 11px;"
Add-Content $fileName "border-top: 1px solid #999999;"
Add-Content $fileName "border-right: 1px solid #999999;"
Add-Content $fileName "border-bottom: 1px solid #999999;"
Add-Content $fileName "border-left: 1px solid #999999;"
Add-Content $fileName "padding-top: 0px;"
Add-Content $fileName "padding-right: 0px;"
Add-Content $fileName "padding-bottom: 0px;"
Add-Content $fileName "padding-left: 0px;"
Add-Content $fileName "}"
Add-Content $fileName "body {"
Add-Content $fileName "margin-left: 5px;"
Add-Content $fileName "margin-top: 5px;"
Add-Content $fileName "margin-right: 0px;"
Add-Content $fileName "margin-bottom: 10px;"
Add-Content $fileName ""
Add-Content $fileName "table {"
Add-Content $fileName "border: thin solid #000000;"
Add-Content $fileName "}"
Add-Content $fileName "-->"
Add-Content $fileName "</style>"
Add-Content $fileName "</head>"
Add-Content $fileName "<body>"
Add-Content $fileName "<table width='100%'>"
Add-Content $fileName "<tr bgcolor='#CCCCCC'>"
Add-Content $fileName "<td colspan='7' height='25' align='center'>"
Add-Content $fileName "<font face='tahoma' color='#003399' size='3'><strong>Veeam 24hr Backup Report - $date</strong></font>"
Add-Content $fileName "</td>"
Add-Content $fileName "</tr>"
Add-Content $fileName "</table>"
}
Function writeGroupTableHeader{
param($fileName, $groupName)
Add-Content $fileName "<table width='100%'><tbody>"
Add-Content $fileName "<tr bgcolor=#CCCCCC>"
Add-Content $fileName "<td width='30%' align='center'><font size='3' face='tahoma' color='#003399'><strong>$groupName</strong></font></td>"
Add-Content $fileName "<td align='center'>"
}
Function writeGroupTableFooter{
param($fileName)
Add-Content $fileName "</td>"
Add-Content $fileName "</tr>"
Add-Content $fileName "</table>"
}
Function writeServerTableHeader{
param($fileName)
Add-Content $fileName "<table width='100%'><tbody>"
Add-Content $fileName "<tr bgcolor=#CCCCCC>"
Add-Content $fileName "<td width='25%' align='center'><font size='2'face='tahoma' color='#003399'><strong>Server Name</strong></font></td>"
Add-Content $fileName "<td width='25%' align='center'><font size='2'face='tahoma' color='#003399'><strong>Status</strong></font></td>"
Add-Content $fileName "<td width='25%' align='center'><font size='2'face='tahoma' color='#003399'><strong>Duration</strong></font></td>"
Add-Content $fileName "<td width='25%' align='center'><font size='2'face='tahoma' color='#003399'><strong>Restore Points</strong></font></td>"
Add-Content $fileName "</tr>"
}
Function writeServerTableData{
param($fileName, $Name, $Status, $Hours, $Minutes, $Seconds, $Count)
$Time = "" + $Hours +":"+ $Minutes +":"+ $Seconds
Add-Content $fileName "<tr bgcolor=#DDDDDD>"
Add-Content $fileName "<td align='center'>$Name</td>"
Add-Content $fileName "<td align='center'>$Status</td>"
Add-Content $fileName "<td align='center'>$Time</td>"
Add-Content $fileName "<td align='center'>$Count</td>"
Add-Content $fileName "</tr>"
}
Function writeServerTableFooter{
param($fileName)
Add-Content $fileName "</table>"
}
Function getData{
param($fileName)
$vbrSessions = Get-VBRBackupSession | ? {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addhours(-24)} | Sort-Object JobName
foreach($session in $vbrSessions){
WriteGroupTableHeader $filename $session.Name
WriteServerTableHeader $filename
$vbrRestorePoints = Get-VBRRestorePoint -backup $session.Name
foreach($vm in $session.gettasksessions()){
$Name = $vm.Name
$Status = $vm.Status
$Duration = $vm.progress.StopTime - $vm.progress.StartTime
$Hours = $Duration.Hours
$Minutes = $Duration.Minutes
$Seconds = $Duration.Seconds
$Count = 0
$Count = ($vbrRestorePoints | ? {$_.Name -match $Name} | Measure-Object).Count
writeServerTableData $fileName $Name $Status $Hours $Minutes $Seconds $Count
}
WriteServerTableFooter $filename
WriteGroupTableFooter $filename
}
}
Function sendEmail{
param($from,$to,$subject,$smtphost,$htmlFileName)
$body = Get-Content $htmlFileName
$smtp= New-Object System.Net.Mail.SmtpClient $smtphost
$msg = New-Object System.Net.Mail.MailMessage $from, $to, $subject, $body
$msg.isBodyhtml = $true
$smtp.send($msg)
}
$filename = "C:\Scripts\VeeamReport.htm"
# Remove the "old" report
Remove-Item $filename -ErrorAction SilentlyContinue
# Create the HTML file
WriteHTMLHeader $filename
# Complete the HTML file
getData $filename
# Setup the email
$subject = "Veeam Backup Report : " + ( Get-Date ).ToString('yyyy/MM/dd')
# Send the Email report
sendEmail veeam@contoso.com allen.kong@contoso.com $subject 10.20.30.40 $fileName
Comments
Post a Comment