HP Matrix 7.2 KVM Private Cloud Backup and Restore

Table Of Contents
Appendix G: Sample Restore Script
An example PowerShell script is provided for uploading and restoring a backup. This script uses PowerShell version
3.0. It makes REST calls to upload and restore a backup. HP highly recommends installing cURL to improve
performance.
How to use the sample restore script
You can copy and paste the sample script into a file on a Windows system that runs PowerShell version 3.0.
HP highly recommends that you install cURL to improve performance. The sample script works without cURL, but it
might take several hours to download a large backup. You can download cURL at
http://curl.haxx.se/download.html. You might also need to install the Microsoft Visual C++ Redistributable,
MSVCR100.dll, which can be downloaded at http://www.microsoft.com/download/en/details.aspx?id=14632 (64
bit) or http://www.microsoft.com/download/en/details.aspx?id=5555 (32 bit). Make sure the path environment
variable includes the path for cURL.
You can run this script interactively to upload and restore a backup or to get status about a restore under way.
To upload and restore a backup, run the script without any parameters. The script will prompt you to enter the
appliance host name, appliance user name and password, and the backup file path. Then the script will upload the
backup, start the restore, and get restore progress information until the restore completes.
To find the status of a restore that is under way, run the script with the -status parameter and the appliance host name
in the form https://{hostname}.
Restore Script
###############################################################################################
############################
# Name: restore.ps1
# Usage: {directory}\restore.ps1 or {directory}\restore.ps1 -status https://{ipaddress}
# Purpose: Uploads a backup file to the appliance and then restores the appliance using the
backup data
# Notes: To improve performance, this script uses the curl command if it is installed
# Created: 7/2/2012
# Modified: 12/4/2012
#(C) Copyright 2012 Hewlett-Packard Development Company, L.P.
###############################################################################################
############################
#tells the computer that this is a trusted soure we are connecting to (brute force, could be
refined)
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
##### Obtain information from user #####
function query-user ()
{
<#
.DESCRIPTION
Obtains information needed to run the script by prompting the user for input.
.INPUTS
None, does not accept piping
.OUTPUTS
Outputs an object containing the obtained information.
.EXAMPLE
$userVals = query-user
#>
Write-Host "Restoring from backup is a destructive process, continue anyway?"
$continue = 0
do
{
$earlyExit = Read-Host
if ($earlyExit[0] -eq 'n')
{
return
}
elseif ($earlyExit[0] -ne 'y')
{
Write-Host "please respond with a y or n"
}
else