EMC VNXe – Gen1&2 Backup Script (Powershell & UEMCLI)

——————————————————————-
Reference:: EMC® VNXe® Unisphere® Command Line Interface User Guide:

Collect -Config: Create a snapshot of the current system configuration and save it to a file. It captures all of the data necessary to recreate the current configuration on a new or reinitialized system. It does not capture log files or other types of diagnostic data.

Collect -serviceInfo: Collect information about the system and save it to a .tar file. Service providers can use the collected information to analyze the system.
——————————————————————-

Using native UEMCLI commands integrated with Powershell this script automates the process of backing up the current VNXe configuration along with the latest system log files. You will just need to Complete a few simple user entries:
◊ Backup Directory
◊ Mgmt IP Address
◊ Service Password

The script will automatically create a sub-directory in the backup location provided. For example if you input a backup directory of C:\VNXe this will result in a backup location of C:\VNXe\timeDate

Example Script Execution
VNXe_Backup1

The backup directory location will automatically open on completion of the script:
VNXe_Backup2

Download: VNXe_Backup.ps1 and remove the .doc extension! Or in full text format below:

 
#################################
#
# Reference: VNXe UEMCLI Docs
# Script:VNXe BACKUPS
# Date: 2015-02-10 17:30:00										 			 
#
# Version Update:                                         
# 1.0 David Ring            	
#					 
#################################

######## Banner ########
Write-Host " "
Write-Host "#########################################################"
Write-Host "#######       VNXe Config and LOGS Backup        ########"
Write-Host "#########################################################"
Write-Host " "


##### Backup Location #####
$BackupLocation = Read-Host "Backup Location:(A sub-dir with the current Time & Date will be created):"
$BackupLocation = (join-path -Path $BackupLocation -ChildPath "$(date -f HHmmddMMyyyy)")	
IF(!(Test-Path "$BackupLocation")){new-item "$BackupLocation" -ItemType directory | Out-Null}
$BackupLocation =  "`"$BackupLocation`""

Write-Host "Backup Location Entered:" $BackupLocation

Start-Sleep -s 3

########################
### VNXe GEN1 Backup ###
########################
$VNXe = Read-Host 'VNXe 3150/3300 Present? y/n:'
if ($VNXe -eq "y") {
$VNXeIP = Read-Host 'VNXe IP Address:'
$VNXePW = Read-Host 'VNXe Service Password:'
Write-Host " "
Write-Host "########################################"
Write-Host "#######  VNXe 3150/3300 Backup  ########"
Write-Host "########################################"
Write-Host " "
Write-Host "VNXe IP Address:" $VNXeIP
Write-Host "VNXe Service Password:" $VNXePW
Write-Host " "
Start-Sleep -s 3
$VNXeConfig = (uemcli.exe -d $VNXeIP -u service -p $VNXePW -download -d $BackupLocation config)
Write-Host "### VNXe Config Backup Complete. ###"
Write-Host " "
Write-Host "### Now Generating VNXe Log Files! ###"
$VNXeConfig = (uemcli.exe -d $VNXeIP -u service -p $VNXePW /service/system collect -serviceInfo)
$VNXeConfig = (uemcli.exe -d $VNXeIP -u service -p $VNXePW -download -d $BackupLocation serviceInfo)
Write-Host " "
Write-Host "##################################################"
Write-Host "#######    VNXe GEN1 Backup Complete      ########"
Write-Host "##################################################"
Write-Host " "
}


########################
### VNXe GEN2 Backup ###
########################
$VNXe = Read-Host 'VNXe 3200 Present? y/n:'
if ($VNXe -eq "y") {
$VNXeIP = Read-Host 'VNXe IP Address:'
$VNXePW = Read-Host 'VNXe Service Password:'
Write-Host " "
Write-Host "####################################"
Write-Host "########  VNXe 3200 Backup  ########"
Write-Host "####################################"
Write-Host " "
Write-Host "VNXe IP Address:" $VNXeIP
Write-Host "VNXe Service Password:" $VNXePW
Write-Host " "
Start-Sleep -s 3
$VNXeConfig = (uemcli.exe -d $VNXeIP -u service -p $VNXePW /service/system collect -config -showPrivateData)
$VNXeConfig = (uemcli.exe -d $VNXeIP -u service -p $VNXePW -download -d $BackupLocation config)
Write-Host "### VNXe Config Backup Complete. ###"
Write-Host " "
Write-Host "### Now Generating VNXe Log Files! ###"
$VNXeLOGS = (uemcli.exe -d $VNXeIP -u service -p $VNXePW /service/system collect -serviceInfo)
$VNXeLOGS = (uemcli.exe -d $VNXeIP -u service -p $VNXePW -download -d $BackupLocation serviceInfo)
Write-Host " "
Write-Host "##################################################"
Write-Host "#######     VNXe GEN2 Backup Complete     ########"
Write-Host "##################################################"
Write-Host " "
}

Start-Sleep -s 3

$BackupLocation = $BackupLocation -replace '"', ""
invoke-item $BackupLocation

Read-Host "Confirm Presence of 'Config File' and 'LOG Files's' in the Backup Directory!"

######################## END ########################

EMC VNX – ArrayConfig & SPCollect (Powershell Script)

——————————————————————-
Reference: VNX® Command Line Interface Reference for Block:

SPCollect : The naviseccli spcollect command selects a collection of system log files and places them in a single .zip file on the system. You can retrieve the file from the system using the managefiles command. Important: The SPCollect functionality can affect system performance (may degrade system performance).

ArrayConfig : The arrayconfig -capture command queries the system for its configuration along with I/O port configuration information. When issued, the command will capture a system’s essential configuration data. The information is formatted and stored on the client workstation. This generated file can be used as a template to configure other systems or rebuild the same system if the previous configuration is destroyed.
——————————————————————-

Using native Navi commands integrated with Powershell this script automates the process of backing up the current VNX configuration along with the latest SPCollect log files. You will just need to Complete a few simple user entries:
◊ SP ‘A’&’B’ IP Addresses
◊ Username & Password
◊ Backup Directory
The script will automatically create a sub-directory in the backup location provided. For example if you input a backup directory of C:\VNX this will result in a backup location of C:\VNX\VNXserial_timeDate

Example Script Input:
SPCScript_1

Expected Script Output:
SPCScript_2

The backup directory location will automatically open on completion of the script:
SPCScript_3

Download HERE and remove .doc extension replacing with .ps1! Or in full text format below:

 

############################
#
# Reference: VNX CLI Docs
# Script: VNX BACKUPS
# 	
# Date: 2015-01-23 14:30:00										 			 
#
# Version Update:                                         
# 1.0 David Ring            	
#					 
############################

######## Banner ########
Write-Host " "
Write-Host "#######################################"
Write-Host "## VNX Configuration & LOGS Backup  ##"
Write-Host "#######################################"


### VNX SP IP's, User/PW & Backup Location ###
$SPAIP = Read-Host 'IP Address for Storage Processor A:'
$SPBIP = Read-Host 'IP Address for Storage Processor B:'
$User = Read-Host 'VNX Username:'
$Password = Read-Host 'VNX Password:'
$BackupLocation = Read-Host "Backup Location:(A sub-dir with the current Time & Date will be created):"

$ArrayConfig = (naviseccli -user $User -password $Password -scope 0 -h $SPAIP getagent | Select-String "Serial No:")
$ArrayConfig = $ArrayConfig -replace “Serial No:”,“”
$ArrayConfig = $ArrayConfig -replace “           ”,“”

$BackupLocation = (join-path -Path $BackupLocation -ChildPath ($ArrayConfig +"_"+ "$(date -f HHmmddMMyyyy)"))	
IF(!(Test-Path "$BackupLocation")){new-item "$BackupLocation" -ItemType directory | Out-Null}
$BackupLocation =  "`"$BackupLocation`""


Write-Host "Storage Processor 'A':" $SPAIP
Write-Host "Storage Processor 'B':" $SPBIP
Write-Host "VNX Username:" $User
Write-Host "VNX Password:" $Password
Write-Host "VNX Serial Number:" $ArrayConfig
Write-Host "Backup Location Entered:" $BackupLocation

Start-Sleep -s 10


$BackupName = $ArrayConfig+"_"+$(date -f HHmmddMMyyyy)+".xml" ; naviseccli -user $User -password $Password -scope 0 -h $SPAIP arrayconfig -capture -output $BackupLocation"\"$BackupName

Write-Host $ArrayConfig "Configuration Data Has Been Backed Up In XML Format!"

Start-Sleep -s 5

### Gather & Retrieve SP Collects for both Storage Processors ###
Write-Host "Now Generating Fresh Storage Processor 'A' & 'B' Collects!"
$GenerateSPA = naviseccli -user $User -password $Password -scope 0 -h $SPAIP spcollect -messner  
$GenerateSPB = naviseccli -user $User -password $Password -scope 0 -h $SPBIP spcollect -messner
Start-Sleep -s 10


### Storage Processor 'A' LOG Collection ###

## WHILE SP_A '*RUNLOG.TXT' FILE EXISTS THEN HOLD ...RESCAN EVERY 90 SECONDS ##
Do {
$listSPA = naviseccli -user $User -password $Password -scope 0 -h $SPAIP managefiles -list | select-string "_runlog.txt"
$listSPA
Start-Sleep -s 90
Write-Host "Generating Log Files For Storage Processor 'A' Please Wait!"
}
While ($listSPA -like '*runlog.txt')  

Write-Host "Generation of SP-'A' Log Files Now Complete! Proceeding with Backup."

Start-Sleep -s 15

$latestSPA = naviseccli -user $User -password $Password -scope 0 -h $SPAIP managefiles -list | Select-string "data.zip" | Select-Object -Last 1
$latestSPA = $latestSPA -split "  "; $latestSPA=$latestSPA[6]
$latestSPA
$BackupSPA = naviseccli -user $User -password $Password -scope 0 -h $SPAIP managefiles -retrieve -path $BackupLocation -file $latestSPA -o

Start-Sleep -s 10


### Storage Processor 'B' LOG Collection ###

## WHILE SP_B '*RUNLOG.TXT' FILE EXISTS THEN HOLD ...RESCAN EVERY 15 SECONDS ##
Do {
$listSPB = naviseccli -user $User -password $Password -scope 0 -h $SPBIP managefiles -list | select-string "_runlog.txt"
$listSPB
Start-Sleep -s 15
Write-Host "Generating Log Files For Storage Processor 'B' Please Wait!"
}
While ($listSPB -like '*runlog.txt')  

Write-Host "Generation of SP-'B' Log Files Now Complete! Proceeding with Backup."

Start-Sleep -s 10

$latestSPB = naviseccli -user $User -password $Password -scope 0 -h $SPBIP managefiles -list | Select-string "data.zip" | Select-Object -Last 1
$latestSPB = $latestSPB -split "  "; $latestSPB=$latestSPB[6]
$latestSPB
$BackupSPB = naviseccli -user $User -password $Password -scope 0 -h $SPBIP managefiles -retrieve -path $BackupLocation -file $latestSPB -o

$BackupLocation = $BackupLocation -replace '"', ""
invoke-item $BackupLocation

Read-Host "Confirm Presence of 'Array Capture XML' and 'SP Collects' in the Backup Directory!"

———————————————-

See Also @Pragmatic_IO post: ‘EMC VNX – Auto Array Configuration Backups using NavisecCLI and Powershell’