HP Matrix 7.2 KVM Private Cloud Backup and Restore

Table Of Contents
.PARAMETER hostname
the appliance to connect to (in https://{ipaddress} format)
.INPUTS
None, does not accept piping
.OUTPUTS
The backup resource object
.EXAMPLE
$backupResource = get-BackupResource $taskResource $sessionID $applianceName
#>
# appends URI (obtained from previous function) to Ip address
$resourceUri = $hostname + $taskResource.associatedResourceUri
# get the backup resource that contains the URI for downloading
try
{
# creates a new webrequest with appropriate headers
$rawResource = setup-request -Uri $resourceUri -method "GET" -accept "application/json" -
auth $authValue
if ($rawResource -ne $null)
{
$resource = $rawResource | convertFrom-Json
if ($global:interactiveMode -eq 1)
{
Write-Host "Obtained backup resource. Now downloading. This may take a while ..."
}
$resource
return
}
}
catch [System.Exception]
{
if ($global:interactiveMode -eq 1)
{
Write-Host $error[0].Exception.Message
}
else
{
Write-EventLog -EventId 100 -LogName Application -Source backup.ps1 -Message
$error[0].Exception.Message
}
}
}
##### Function to download the backup file #####
function download-Backup ([PSCustomObject]$backupResource,[string]$authValue,[string]$hostname)
{
<#
.DESCRIPTION
Downloads the backup file from the appliance to the local system. Tries to use the
curl command. The curl command has significantly better performance especially for
large backups. If curl isn't installed, invokes download-Backup-without-curl to
download the backup.
.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
.OUTPUTS
The absolute path of the download file
.EXAMPLE
download-backup $backupResource $sessionID https://11.111.11.111
#>
43