HP Matrix 7.2 KVM Private Cloud Backup and Restore

Table Of Contents
$rawStatus = setup-request -Uri $fullStatusUri -method "GET" -accept "application/json" -
authValue $authValue -isSilent 1
# converts the response from the Appliance into a hash table
$taskStatus = $rawStatus | convertFrom-Json
# checks the status of the task manager
$status = $taskstatus.taskState
}
catch
{
$errorMessage = $error[0].Exception.Message
$errorCount = $errorCount + 1
$status = "RequestFailed"
Start-Sleep -s 15
continue
}
# Update progress bar
if ($global:interactiveMode -eq 1)
{
$trimmedPercent = ($taskStatus.completedSteps) / 5
$progressBar = "[" + "=" * $trimmedPercent + " " * (20 - $trimmedPercent) + "]"
Write-Host "`r Backup progress: $progressBar " $taskStatus.completedSteps "%" -NoNewline
}
# Reset the error count since status was successfully retrieved
$errorCount = 0
# If the backup is still running, wait a bit, and then check again
if ($status -eq "Running")
{
Start-Sleep -s 10
}
} while (($status -eq "Running" -or $status -eq "RequestFailed") -and $errorCount -lt 20);
# if the backup reported an abnormal state, report the state and exit function
if ($status -ne "Completed")
{
if ($global:interactiveMode -eq 1)
{
Write-Host "`n"
Write-Host "Backup stopped abnormally"
Write-Host $errorMessage
}
else
{
#log error message
Write-EventLog -EventId 100 -LogName Application -Source backup.ps1 -Message "Backup
stopped abnormally"
Write-EventLog -EventId 100 -LogName Application -Source backup.ps1 -Message
$errorMessage
}
return $null
}
# upon successful completion of task, outputs a hash table which contains task resource
else
{
Write-Host "`n"
$taskStatus
return
}
}
##### Gets the backup resource #####
function get-backupResource ([object]$taskResource,[string]$authValue,[string]$hostname)
{
<#
.DESCRIPTION
Gets the URI for the backup resource from the task resource and gets the backup
resource
.PARAMETER taskResource
The task resource object that we use to get the URI for the backup manager
.PARAMETER authValue
The authorized sessionID
42