|
| 1 | +############################################################################################################################## |
| 2 | +# VolumeSet Example - Create or Modify |
| 3 | +# |
| 4 | +# Scenario: |
| 5 | +# This script will show examples in how to initially create a Volume Set, and what has to be changed if you need |
| 6 | +# Modify the number of volumes in the Volume Set. |
| 7 | +# Prerequisities: |
| 8 | +# 1. Install the PureStorage.FlashArray.Backup module |
| 9 | +# 2. Have FlashArray administrator, Windows Server, and if a VMware VM, vCenter credentials. |
| 10 | +# |
| 11 | +# Usage Notes: |
| 12 | +# These simple example show how to initially create and later modify a Volume Set that can be used |
| 13 | +# for creating snapshots and mounting those snapshots. |
| 14 | +# |
| 15 | +# Disclaimer: |
| 16 | +# This example script is provided AS-IS and meant to be a building block to be adapted to fit an individual |
| 17 | +# organization's infrastructure. |
| 18 | +############################################################################################################################## |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +# Import powershell modules |
| 23 | +Import-Module PureStorage.FlashArray.Backup |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +# Declare variables |
| 28 | +$SourceSQLServer = 'SqlServer1' # Name of source SQL Server |
| 29 | +$SourceArrayName = 'flasharray1.example.com' # Source FlashArray FQDN |
| 30 | +$ProtectionGroupName = 'SqlServer1_Pg' # Protection Group name in the FlashArray |
| 31 | +$VolumeSet = 'volset1' # Name of the Volume Set |
| 32 | +$SourcePath = 's:\' # Path of Volumes to Snapshot |
| 33 | +$VolumeType = 'vvol' # Physical, vVol, or RDM |
| 34 | +$vCenterAddress = 'vcenter.example.com' # vCenter Server |
| 35 | +$SourceVMName = 'sqlvm4' # Source VM |
| 36 | + |
| 37 | +# Set Credentials - this assumes the same credential for the target SQL Server and the FlashArray. If this is a VMware VM using pRDM or vVol, a vCenter credential is required. |
| 38 | +$FlashArrayCredential = Get-Credential |
| 39 | +$SQLServerCredential = Get-Credential |
| 40 | +$vCenterCredential = Get-Credential |
| 41 | + |
| 42 | +# Volume Sets can be manually created by specifying a set of volumes on a target Windows Server. |
| 43 | +# New-PsbVolumeSet will connected to the declared ComputerAddress and match the drive letters and mount points |
| 44 | +# to the corresponding volumes on the FlashArray. If VMware RDM/vVol additional parameters are required to |
| 45 | +# assist in matching those supported disk types to Pure Storage Volumes. |
| 46 | + |
| 47 | +# Example 1: Create a new volume set where the target computeraddress is a server that has a Host Record on |
| 48 | +# the FlashArray. This includes vHBA, in-guest iSCSI, and bare metal servers. |
| 49 | + |
| 50 | +$VolumeType = 'Physical' |
| 51 | +New-PsbVolumeSet -VolumeSetName $VolumeSet -ComputerAddress $SourceSQLServer -ComputerCredential $SQLServerCredential -FlashArrayAddress $SourceArrayName -FlashArrayCredential $FlashArrayCredential -Path $SourcePath -VolumeType $VolumeType |
| 52 | + |
| 53 | +# Example 2: Create a new volume set where the target computeraddress is a VMware VM using physical RDMs. |
| 54 | +# Note the query for the VMPID is optional, but if that is not passed and VM is renamed in vCenter, |
| 55 | +# it will fail to find the VM if the -VMname parameter is not modified to the new VM name. |
| 56 | +$VMPID = Get-PSBVMPersistentId -VCenterAddress $vCenterAddress -VCenterCredential $vCenterCredential -VMName $SourceVMName |
| 57 | +$VolumeType = 'RDM' |
| 58 | +New-PsbVolumeSet -VolumeSetName $VolumeSet -ComputerAddress $SourceSQLServer -ComputerCredential $SQLServerCredential -FlashArrayAddress $SourceArrayName -FlashArrayCredential $FlashArrayCredential -Path $SourcePath -VolumeType $VolumeType -VCenterAddress $vCenterCredential -VMName $SourceVMName -VMPersistentId $VMPID |
| 59 | + |
| 60 | +# Example 3: Create a new volume set where the target computeraddress is a VMware VM using virtual volumes (vVol). |
| 61 | +# Note the query for the VMPID is optional, but if that is not passed and VM is renamed in vCenter, |
| 62 | +# it will fail to find the VM if the -VMname parameter is not modified to the new VM name. |
| 63 | +$VMPID = Get-PSBVMPersistentId -VCenterAddress $vCenterAddress -VCenterCredential $vCenterCredential -VMName $SourceVMName |
| 64 | +$VolumeType = 'vvol' |
| 65 | +New-PsbVolumeSet -VolumeSetName $VolumeSet -ComputerAddress $SourceSQLServer -ComputerCredential $SQLServerCredential -FlashArrayAddress $SourceArrayName -FlashArrayCredential $FlashArrayCredential -Path $SourcePath -VolumeType $VolumeType -VCenterAddress $vCenterCredential -VMName $SourceVMName -VMPersistentId $VMPID |
| 66 | + |
| 67 | +# Example 4: Building upon Example 1 |
| 68 | +# Modify a volume set by adding a disk in the path. In this example the Volume Set already exists, and only |
| 69 | +# one disk, the 's:\' disk, is in the volume set. The Invoke-PsbSnapshotJob will see the drive letters |
| 70 | +# and mount points in the path, and check that they are all marked as belonging to the Volume Set. If any of the |
| 71 | +# declared volumes are not in the volume set, powershell will ask you to confirm overwriting the volume set on |
| 72 | +# the FlashArray with the new set of disks. Simply changing the -Path parameter is not sufficient, as all |
| 73 | +# volumes declared in the -path must be members of the declared -pgroupname or the invoke-psbsnapshotjob will fail |
| 74 | +# with an error indicating that all of the volumes in the Volume Set are not members of the declared Protection Group. |
| 75 | + |
| 76 | +$SourcePath = 's:\,t:\' # Path of Volumes to Snapshot |
| 77 | +Invoke-PsbSnapshotJob -vcenteraddress $vcenteraddress -VcenterCredential $vcentercredential -vmname $sourceVMName -FlashArrayAddress $SourceArrayName -FlashArrayCredential $FlashArrayCredential -VolumeSetName $VolumeSet -VolumeType $VolumeType -ComputerAddress $SourceSQLServer -ComputerCredential $SQLServerCredential -Path $SourcePath -pgroupname $ProtectionGroupName |
| 78 | + |
| 79 | +# Example 5: Building upon Example 4 |
| 80 | +# Modify a volume set by removing a disk in the path. In this example the Volume Set already exists, and |
| 81 | +# two disks the 's:\,t:\' disks are members of the volume set. The Invoke-PsbSnapshotJob will see the drive letters |
| 82 | +# and mount points in the path, and check that they are all marked as belonging to the Volume Set. If any volumes on |
| 83 | +# the FlashArray are members of the Volume Set but not included in the -path parameter, powershell will ask you to |
| 84 | +# confirm overwriting the volume set on the FlashArray with the new set of disks. This action will not remove |
| 85 | +# volumes from the declared protection group. |
| 86 | + |
| 87 | +$SourcePath = 's:\' # Path of Volumes to Snapshot |
| 88 | +Invoke-PsbSnapshotJob -vcenteraddress $vcenteraddress -VcenterCredential $vcentercredential -vmname $sourceVMName -FlashArrayAddress $SourceArrayName -FlashArrayCredential $FlashArrayCredential -VolumeSetName $VolumeSet -VolumeType $VolumeType -ComputerAddress $SourceSQLServer -ComputerCredential $SQLServerCredential -Path $SourcePath -pgroupname $ProtectionGroupName |
0 commit comments