How-To: Working with Snapshots and the Powershell SDK v2
The Connect-Pfa2Array
cmdlet caches authentication information for the duration of the PowerShell session. With this, subsequent SDK cmdlets do not need to explicitly provide the -Array
parameter. The cmdlets will retrieve the FlashArray authentication information from PowerShell session variable. However, if more than one array connection is established in a PowerShell session, then the -Array
parameter must be used.
Creating Snapshots
Volume Snapshots
Creating snapshots for volumes is done using the New-Pfa2VolumeSnapshot
cmdlet.
PS >New-Pfa2VolumeSnapshots -Array $FlashArray -SourceNames 'SDKv2-sample-1','SDKv2-sample-2' -Suffix 'EXAMPLE'
To create a new volume from a snapshot, we must first create a Reference Object for the snapshot. The first output from Get-Pfa2VolumeSnapshot
is trimmed to only show the necessary objects.
PS >Get-Pfa2VolumeSnapshot -Name 'SDKv2-sample-1.EXAMPLE' Id : 47f25a22-fda3-f163-c695-94a6c984b0af Name : SDKv2-sample-1.EXAMPLE ... PS >$src = New-Pfa2ReferenceObject -Id 47f25a22-fda3-f163-c695-94a6c984b0af -Name SDKv2-sample-1.EXAMPLE
Now, we will create a new volume from the snapshot using New-Pfa2Volume
.
PS >New-Pfa2Volume -Name SDKv2-volumecopy -Source $src
Protection Group Snapshots
A Protection Group snapshot creates a point-in-time snapshot of the contents of a Protection Group. The New-Pfa2ProtectionGroupSnapshot
cmdlet is used.
PS >New-Pfa2ProtectionGroupSnapshot -Array $FlashArray -SourceNames DEMO-PGGROUP -Suffix TEST Name : demo-pggroup.TEST Created : 8/1/2020 3:13:39 PM Destroyed : False Pod : class FixedReference { Id: Name: } Source : class FixedReference { Id: Name: demo-pggroup } Space : Suffix : TEST TimeRemaining :
Destroying (Removing) and Eradicating Snapshots
There are two steps in completely removing a snapshot from an array, Destroy and Eradicate. When a snapshot is removed, it is tagged as Destroyed=$true (visible with the Get-Pfa2VolumeSnapshot
cmdlet) and is maintained in that state for a set period of time. A snapshot is recoverable while in this state. When eradicated, the snapshot is completely removed from the array and the snapshot can no longer be recovered. Depending on the type of snapshot that is being removed, the cmdlets used share the common parameters needed to remove the snapshots.
To perform this two-step process, a snapshot must be Updated to set the "Destroyed" property to $true
by using the Update-*
cmdlets, and then eradicated with the Remove-*
cmdlets as shown in the examples below.
A snapshot must be destroyed before it can be eradicated.
Volume Snapshots
To Destroy a snapshot, use the Update-Pfa2VolumeSnapshot
cmdlet. The -Id
and -Name
parameters must be specified.
PS >Update-Pfa2VolumeSnapshot -Array $FlashArray -Id <ID_of_snapshot> -Name <Name_of_snapshot>
To make it easier to obtain the snapshot information, you can also use it with the Get-Pfa2VolumeSnapshot
cmdlet and pipeline the results to the Update-Pfa2VolumeSnapshot
cmdlet. You can also perform the action against multiple snapshots in a single command.
# For a single snapshot named DEMO-VOL1.TEST PS >Get-Pfa2VolumeSnapshot -Array $FlashArray -Name 'DEMO-VOL1.TEST' | Update-Pfa2VolumeSnapshot # For multiple snapshots that have similiar names PS >Get-Pfa2VolumeSnapshot -Array $FlashArray | Where-Object { $_.name -like 'DEMO*' } | Update-Pfa2VolumeSnapshot
To revert a snapshot that has been set as "Destroyed", change the -Destroyed
parameter to $false
.
To Eradicate the snapshot, add the -Eradicate
and optional -Confirm
parameter.
# For a single snapshot amed DEMO-VOL1.TEST PS >Get-Pfa2VolumeSnapshot -Array $FlashArray -Name 'DEMO-VOL1.TEST' | Remove-Pfa2VolumeSnapshot -Eradicate -Confirm # For multiple snapshots that have similiar names PS >Get-Pfa2VolumeSnapshot -Array $FlashArray | Where-Object { $_.name -like 'DEMO*' } | Remove-Pfa2VolumeSnapshot -Eradicate -Confirm
Protection Group Snapshots
To Destroy a Protection Group snapshot using a cmdlet pipeline, the Update-Pfa2ProtectionGroupSnapshot
cmdlet is added to the Get-Pfa2ProtectionGroupSnapshot
cmdlet with the -Destroyed
parameter to set the "Destroyed" property to $true
.
PS >Get-Pfa2ProtectionGroupSnapshot -Array $FlashArray -Name 'DEMO-PGGROUP.TEST' | Update-Pfa2ProtectiongroupSnapshot -Destroyed $true Name : demo-pggroup.TEST Created : 8/1/2020 3:13:39 PM Destroyed : True Pod : class FixedReference { Id: Name: } Source : class FixedReference { Id: Name: demo-pggroup } Space : Suffix : TEST TimeRemaining : 86399000
To revert a snapshot that has been set as "Destroyed", change the -Destroyed
parameter to $false
.
To Eradicate the snapshot, use the Remove-Pfa2ProtectionGroupSnapshot
cmdlet.
PS >Get-Pfa2ProtectionGroupSnapshot -Array $FlashArray -Name 'DEMO-PGGROUP.TEST' | Remove-Pfa2ProtectionGroupSnapshot
Copying Snapshots to Volumes
In the SDK version 2.x, the process to create a volume (Copy Volume) from a snapshot requires a Reference Object be created to identify the snapshot. This section includes information on how to create volumes from volume snapshots, Host Group snapshots, and Protection Group snapshots.
Host Volumes
The process of creating a Reference Object for a snapshot is similar across the use cases. Obtain the snapshot information, set the Reference Object, and execute against that object. The New-Pfa2ReferenceObject
cmdlet is used to set a variable for the snapshot object. When creating a Reference Object use either the -Id or -Name but not both. Examples shown below.
Using -Id parameter.
# Retrieve the snapshot information # This will retrieve the ID of the snapshot PS >Get-Pfa2VolumeSnapshot -Array $FlashArray -Name 'DEMO-VOL1.TEST' | Format-Table -Property ID # Create the reference object fot the snapshot and set the variable PS >$src = New-Pfa2ReferenceObject -Id <returned snapshot ID>
Using -Name parameter.
# Retrieve the snapshot information # This will retrieve the Name of the snapshot PS >Get-Pfa2VolumeSnapshot -Array $FlashArray -Name 'DEMO-VOL1.TEST' | Format-Table -Property Name # Create the reference object fot the snapshot and set the variable PS >$src = New-Pfa2ReferenceObject -Name <returned snapshot Name>
Now that the $src
variable has been set with either the -Id or -Name parameter with the Reference Object of the snapshot, we can create a volume using the New-Pfa2Volume
cmdlet as shown.
PS >New-Pfa2Volume -Array $FlashArray -Name volumecopy -Source $src
Protection Group Snapshot Schedules
Protection Group Snapshot schedules control the timing and frequency of when snapshots are automatically taken for a Protection Group. TheNew
-Pfa2SnapshotScheduleObject
cmdlet is used to create an object to update the Protection Group with the Update-Pfa2protectiongroup cmdlet
.
The time factors used for these parameters is in milliseconds. The -At
parameter is the time of day the snapshot is scheduled to be taken and retained on the local array or immediately replicated to the target(s). It is measured in milliseconds since midnight. The -At
parameter is only used if the -Frequency
parameter is in days, (e.g., `259200000`, which is equal to 3 days).
# Retrieve the snapshots for the Protection Group PS >Get-Pfa2ProtectionGroupSnapshot -Array $FlashArray -Name 'demo-pggroup' # Retrieve the snapshot properties PS >$schedule = Get-Pfa2ProtectionGroup -Array $FlashArray -Name 'demo-pggroup' # Display only the snapshot schedule PS >$schedule.SnapshotSchedule # Create the new snapshot schedule object with time and frequency and set it to enabled. PS >$snapschedule=New-Pfa2SnapshotScheduleObject -At 7200000 -Enabled $true -Frequency 259200000 # Update the Protection Group with the new schedule PS >Update-Pfa2ProtectionGroup -Name 'demo-pggroup' -SnapshotSchedule $snapschedule Name : demo-pggroup Destroyed : False HostCount : HostGroupCount : IsLocal : True Pod : class FixedReference { Id: Name: } ReplicationSchedule : class ReplicationSchedule { At: Enabled: False Frequency: 14400000 Blackout: class TimeWindow { Start: End: } } SnapshotSchedule : class SnapshotSchedule { At: Enabled: False Frequency: 3600000 } SourceRetention : class RetentionPolicy { AllForSec: 86400 Days: 7 PerDay: 4 } Space : TargetCount : TargetRetention : class RetentionPolicy { AllForSec: 86400 Days: 7 PerDay: 4 } TimeRemaining : VolumeCount :
Snapshot Transfer Statistics
You can retrieve the transfer statistics for snapshots of Volumes or Protection Groups. For volumes, use the Get-Pfa2VolumeSnapshotTransfer
cmdlet, and for protection groups, use the Get-Pfa2ProtectionGroupSnapshotTransfer
cmdlet. Both cmdlets have similar parameters.
PS> Get-Pfa2VolumeSnapshotTransfer -Array $FlashArray -Name 'DEMO-VOL1.TEST' Name : DEMO-VOL1.TEST Completed : 8/1/2020 2:38:18 PM DataTransferred : 41122875 Destroyed : False PhysicalBytesWritten : 40060829 Progress : 1 Started : 8/1/2020 2:38:05 PM
For protection Group snapshots-
PS> Get-Pfa2ProtectiongroupSnapshotTransfer -Array $FlashArray -Name 'PGDEMO-VOL1.TEST' Name : PGDEMO-VOL1.TEST Completed : 8/1/2020 2:44:22 PM DataTransferred : 41290179 Destroyed : False PhysicalBytesWritten : 40215252 Progress : 1 Started : 8/1/2020 2:41:53 PM
Since the Get-Pfa2VolumeSnapshotTransfer
and Get-Pfa2ProtectionGroupSnapshotTransfer
cmdlets accept pipeline input, you could create a command to post the output from a Get-Pfa2VolumeSnapshot
or Get-Pfa2ProtectiongroupSnapshot
cmdlet to the same transfer cmdlet for scripting, as shown below.
PS> Get-Pfa2VolumeSnapshot -Array $FlashArray -Name 'DEMO-VOL1.TEST' | Get-Pfa2VolumeSnapshotTransfer
PS> Get-Pfa2ProtectionGroupSnapshot -Array $FlashArray -Name 'DEMO-VOL1.TEST' | Get-Pfa2ProtectionGroupSnapshotTransfer