PowerShell, Technology

Simplivity Backup Reports with PowerShell

An issue with Flash in the web browser and the version of Simplivity we are running forced my hand to learn to manage the backups using PowerShell. I started managing the backups through the Simplivity CLI but then discovered there was an PowerShell API which made life a lot easier. If you have experience using PowerShell you will find these commands easy to pick up. I was also able to create a Daily Report that I schedule to email me each day.

HPE Simplivity PowerShell Module

This website has everything you need for installing and using the module:

https://developer.hpe.com/blog/hpe-simplivity-powershell-module/

Install the module:

PS C:\> Install-Module -Name HPESimpliVity

Connect to OVC:

PS C:\> $Cred = Get-Credential -Message 'Enter OVC/MVA Credentials'
PS C:\> Connect-SVT -OVC -Credential $Cred

and away you go!

You will find all the commands on the page listed above.

Examples

1- Create Manual backup and retain for 4 days

New-SVTbackup -VmName SRV1-DestinationName DR -BackupName SRV1_ManualBackup -RetentionDay 4

2- Get all backups for server “SRV1” on the “DR” cluster that were created before 31st December 2020

Get-SVTbackup -VmName SRV1 -DestinationName DR -CreatedBefore "31/12/2020"

Backup Report

This is a simple Daily Report I created which gives me:

  • Host storage information
  • Lists any failed backups
  • Lists the last 200 backups (VM name, Backup state, Destination, Sent MB)

Here is an example of the Report:

To be honest, the hardest thing about setting up this report for me was getting the HTML right so it formats properly. Getting the data I needed was relatively easy.

Below is the code I used for my report. I set this to run as a scheduled task daily.

#Date Information to be used in the headers
$TodaysDate = (Get-Date).ToString('yyyy-MM-dd')
$LastWeek = (Get-Date).Adddays(-7).ToString('dd/MM/yyyy')

#Get Creds to login to OVC. This is covered in the https://developer.hpe.com/blog/hpe-simplivity-powershell-module/
$Cred = Import-CLIXML .\OVCcred.XML

#Connect to OVC
Connect-SVT -OVC (IP of your OVC) -Credential $cred

#Location to save report
$reportLocation = "\\Server\Reports\SimplivityReport-$TodaysDate.html"

#Create HTML Table
$head = @’
<style>
body { background-color:#dddddd;
font-family:Tahoma;
font-size:12pt; }
td, th { border:1px solid black;
border-collapse:collapse; }
th { color:white;
background-color:black; }
table, tr, td, th { padding: 2px; margin: 0px }
table { margin-left:50px; }
</style>
‘@


#-------Building Report--------------#

#Get Host Information - Name, Cluster, Freespace, Usedspace, IP
$hostInfo = Get-SVThost | Select HostName, ClusterName, FreeSpaceGB, UsedCapacityGB,ManagementIP | ConvertTo-Html -PreContent "<h2>Host Information</h2>" | Out-String

#Get backups with the backup state "Failed" that were created in the last week 
$FailedBackups =""
Try
{
$FailedBackups = Get-SVTbackup -BackupState FAILED -CreatedAfter $LastWeek |Select VMNAme, BackupState, CreateDate, DestinationName | ConvertTo-Html -PreContent "<h2>Failed Backups</h2>" | Out-String
}
catch { $FailedBackups = ConvertTo-Html -PreContent "<h2>No FAILED Backups found</h2>" | Out-String }

#GEt last 200 backups
$Last200Backups = GEt-SVTBackup -limit 200 -Hour 1000| Select VMNAme, BackupState, CreateDate, DataStoreName, DestinationName, SentMB, SizeGB | ConvertTo-Html -PreContent "<h2>Last 200 Backups</h2>" | Out-String

#Set Display Title
$DisplayTitle = "Simplivity Server Report: " + (Get-Date).ToString('dd/MM/yyyy')

#Create Report
ConvertTo-Html -Head $head -Title "Simplivity Report" -Body (GEt-date) -PostContent $hostInfo,$FailedBackups, $Last200Backups -PreContent “<h1>$DisplayTitle</h1>” > $reportLocation




Leave a Reply

Your email address will not be published. Required fields are marked *