HP Matrix 7.2 KVM Private Cloud Backup and Restore

Table Of Contents
$downloadUri = $hostname + $backupResource.downloadUri
$fileDir = [environment]::GetFolderPath("Personal")
$filePath = $fileDir + "\" + $backupResource.id + ".bkp"
$curlDownloadCommand = "curl -o " + $filePath + " -s -f -L -k -X GET " +
"-H 'accept: application/octet-stream' " +
"-H 'auth: " + $authValue + "' " +
"-H 'X-API-Version: 1' " +
$downloadUri
$curlGetDownloadErrorCommand = "curl -s -k -X GET " +
"-H 'accept: application/json' " +
"-H 'auth: " + $authValue + "' " +
"-H 'X-API-Version: 1' " +
$downloadUri
try
{
invoke-expression $curlDownloadCommand
if ($LASTEXITCODE -ne 0)
{
$errorResponse = invoke-expression $curlGetDownloadErrorCommand
if ($global:interactiveMode -eq 1)
{
Write-Host "Download error: $errorResponse"
}
else
{
Write-EventLog -EventId 100 -LogName Application -Source backup.ps1 -Message
"Download error: $errorResponse"
}
if (Test-Path $filePath)
{
Remove-Item $filePath
}
return
}
if ($global:interactiveMode -eq 1)
{
Write-Host "Backup download complete!"
}
}
catch [System.Management.Automation.CommandNotFoundException]
{
return download-Backup-without-curl $backupResource $authValue $hostname
}
catch [System.Exception]
{
Write-Host "Not able to download backup"
Write-Host $error[0].Exception
return
}
return $filePath
}
##### Function to download the Backup file without using the curl command #####
function download-Backup-without-curl
([PSCustomObject]$backupResource,[string]$authValue,[string]$hostname)
{
<#
.DESCRIPTION
Downloads the backup file from the appliance to the local system (without using
curl)
.PARAMETER backupResource
Backup resource containing URI for downloading
.PARAMETER authValue
The authorized sessionID
.PARAMETER hostname
The IP address of the appliance
.INPUTS
None, does not accept piping
44