HP Insight Control Server Provisioning 7.2 Administrator Guide

3.2.3 Sample backup script
An example PowerShell script is provided for creating and downloading a backup. The sample
script is available on the Insight Control server provisioning media and in the product download
zip file.This script uses PowerShell version 3.0. It makes REST calls to create and download a
backup. The sample script can be scheduled to run automatically on a regular basis.
3.2.3.1 How to use the sample backup 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 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 or in batch mode. To run the script interactively, run it without
any parameters. The script will prompt you to enter the appliance host name, appliance user name
and password, and the name of a file for storing these parameters for batch mode executions.
Enter the name and password of a user with the Backup Administrator or Infrastructure Administrator
role. The user name and password will be stored encrypted. To run the script in batch mode,
specify the name of the file containing the parameters on the command line.
HP recommends you run the script interactively the first time. Then you can schedule the script to
run automatically in the background using the parameter file created by the first run.
You can edit the sample script to customize it for your environment.
3.2.3.2 Example output
Enter Appliance name (https://ipaddress)
https://10.10.10.10
Enter Username
*************
Enter password
********
Would you like to save these credentials to a file? (username and password encrypted)
y
Enter file path and file name to save credentials (example: C:\users\bob\machine1.txt)
C:\users\jerry\jerry-vm.txt
The file 'C:\users\jerry\jerry-vm.txt' already exists.
Overwrite existing credentials for this machine?
y
run backup?
y
Login completed successfully.
Backup initiated.
Checking for backup completion, this may take a while.
Backup progress: [====================] 100 %
Obtained backup file URI, now downloading
Backup download complete!
Backup can be found at C:\Users\jerry\Documents
If you wish to automate this script in the future and re-use login settings currently entered,
then provide the file path to the saved credentials file when running the script.
ie: C:\Users\jerry\backup.ps1 filepath
3.2.3.3 Sample backup script main processing and functions
The sample script does the following to create and download a backup:
1. Calls queryfor-credentials() to get the appliance host name, user name, and password
by either prompting the user or reading the values from a file.
2. Calls login-appliance() to issue a REST request to obtain a session ID used to authorize
backup REST calls.
3.2 Creating and downloading an appliance backup 15