HP OneView Manual del usuario

Página 292

Advertising
background image

Ejemplo 9 Secuencia de comandos restore.ps1 de ejemplo

#(C) Copyright 2013 Hewlett-Packard Development Company, L.P.
###########################################################################################################################
# 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. The curl command
# must be installed with the SSL option.
# Windows PowerShell 3.0 must be installed to run the script
###########################################################################################################################

#Notifies the computer that this is a trusted source we are connecting to (brute force, could be refined)
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }

# The scriptApiVersion is the default Api version (if the appliance supports this level
# or higher). This variable may be changed if the appliance is at a lower Api level.
$global:scriptApiVersion = 3

##### 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
{
$continue = 1
}

} while ($continue -eq 0)

do
{
Write-Host "Enter directory backup is located in (ie: C:\users\joe\)"
$backupDirectory = Read-Host
# Add trailing slash if needed
if (!$backupDirectory.EndsWith("\"))
{
$backupDirectory = $backupDirectory + "\"
}

Write-Host "Enter name of backup (ie: appliance_vm1_backup_2012-07-07_555555.bkp)"
$backupFile = Read-Host

# Check if file exists
$fullFilePath = $backupDirectory + $backupFile
if (! (Test-Path $fullFilePath))
{
Write-Host "Sorry the backup file $fullFilePath doesn't exist."
}
} while (! (Test-Path $fullFilePath))

Write-Host "Enter appliance IP address (ie: https://10.10.10.10)"
$hostname = Read-Host
# Correct some common errors

292 Ejemplos de secuencias de comandos de copia de seguridad y restauración

Advertising