How-To: Working with Snapshots and the Powershell SDK v1
More examples can be found in our GitHub repository example file.
Creating Snapshots
Volume Snapshots
Creating a snapshot of a volume is done with the New-PfaVolumeSnapshots
cmdlet.
New-PfaVolumeSnapshots -Array $FlashArray -Sources 'TEST-VOL1','TEST-VOL2' -Suffix 'EXAMPLE'
Protection Group Snapshots
A Protection Group snapshot creates a point-in-time snapshot of the contents of a Protection Group. The New-PfaProtectionGroupSnapshot
cmdlet is used.
PS >New-PfaProtectionGroupSnapshot -Array $FlashArray -Protectiongroupname 'TEST-PGROUP' -Suffix 'EXAMPLE'
Retrieving current Protection Group Snapshot information
$pgs = Get-PfaProtectionGroups -array $FlashArray | Select-Object Name foreach ($pg in $pgs) { Get-PfaProtectionGroupSnapshots -array $FlashArray -Name $pg.name | Select-Object Name,created | Format-Table -AutoSize }
Destroying, Eradicating, Restoring, and Moving 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-PfaVolumeSnapshots
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 "Destroyed" and then it can be "Eradicated" with the -Eradicate parameter as shown in the examples below.
A snapshot must be destroyed before it can be eradicated.
Volume Snapshots
To Destroy a snapshot, use the Remove-PfaVolumeOrSnapshot
cmdlet. The -array
and -Name
parameters must be specified.
PS >Remove-PfaVolumeOrSnapshot -Array $FlashArray -Name <Name_of_snapshot>
To make it easier to delete volume snapshots older than a set amount of days of retention, you can use this script with the Get-PfaVolumeSnapshots
cmdlet as show below:
$purevolume = "nameofvolume" $retention = (Get-Date).adddays(-10) #$retention = (get-date).adddays(-10) $ListAllSnap = Get-PfaVolumeSnapshots -VolumeName $purevolume -Array $pfa30 $ListAllSnap | ForEach-Object { if ($_.created -lt $retention) { Write-Host $_.created "deleted" Remove-PfaVolumeOrSnapshot -array $pfa30 -name $_.name } else { Write-Host $_.created "saved" } }
To Eradicate the snapshot, add the -Eradicate
and optional -Confirm
parameter. use the Get-PfaPendingDeleteVolumeSnapshots
cmdlet to view the volumes that are able to be eradicated.
# View the snapshots that are pending eradication PS >Get-PfaPendingDeleteVolumeSnapshots -Array $FlashArray # Eradicate a snapshot PS >Remove-PfaVolumeOrSnapshot -Array $FlashArray -Name DEMO_TEST_SNAPSHOT -Eradicate -Confirm
To recover a destroyed, but not Eradicated, volume snapshot. This cmdlet would work the same for a Protection Group snapshot.
PS >Restore-PfaDestroyedVolumeSnapshot -Array $FlashArray -Name DEMO_TEST_SNAPSHOT
Moving a snapshot allows you to place the snapshot inside of a existing container (a Volume or Pod) on an array. To move a snapshot, use the Move-PfaVolumeOrSnapshot
cmdlet.
PS >Move-PfaVolumeOrSnapshot -Array FlashArray -Name DEMO_TEST_SNAPSHOT -Container VolGroup1
Protection Group Snapshots
To retrieve a list of snapshots for a Protection Group, use the Get-PfaProtectionGroupSnapshots
cmdlet.
PS >Get-PfaProtectionGroupSnapshots -Array $FlashArray -Name 'TEST-PGROUP'
To Destroy and/or Eradicate a snapshot, use the Remove-PfaProtectionGroupOrSnapshot
cmdlet.
# Destroy the snapshot PS >Remove-PfaProtectionGroupOrSnapshot -Array $FlashArray -Name 'DEMO-PGGROUP.TEST' # Eradicate the snapshot PS >Remove-PfaProtectionGroupOrSnapshot -Array $FlashArray -Name 'DEMO-PGGROUP.TEST' -Eradicate -Confirm
Copying Snapshots to Volumes
Host Volumes
in the following example, the TEST-VOL1.EXAMPLE snapshot is created and is then copied to a new host volume NEW-TEST-VOL1.
PS >New-PfaVolumeSnapshots -Array $FlashArray -Sources 'TEST-VOL1','TEST-VOL2' -Suffix 'EXAMPLE' PS >New-PfaVolume -Array $FlashArray -Source 'TEST-VOL1.EXAMPLE' -VolumeName 'NEW-TEST-VOL1'
To overwrite an existing volume with a snapshot, use the -Overwrite
parameter as shown below:
PS >New-PfaVolume -Array $FlashArray -Source 'TEST-VOL2.EXAMPLE' -VolumeName 'TEST-VOL2' –Overwrite
Protection Group Snapshot Schedules
Protection Group Snapshot schedules control the timing and frequency of when snapshots are automatically taken for a Protection Group.
# Retrieve the snapshots for the Protection Group PS >Get-PfaProtectionGroupSchedule -Array $FlashArray -ProtectionGroupName 'TEST-PGROUP' # Set the Protection Group schedule PS >Set-PfaProtectionGroupSchedule -Array $FlashArray -SnapshotFrequencyInSeconds 21600 -GroupName 'TEST-PGROUP' # Enable the new snapshot schedule. PS >Enable-PfaSnapshotSchedule -Array $FlashArray -Name 'TEST-PGROUP' # Disable a snapshot schedule PS >Disable-PfaSnapshotSchedule -Array $FlashArray -Name 'TEST-PGROUP'
Offload Target Snapshots
There are specific cmdlets that work with Offload Targets, both Volume and Protection Group targets, in the SDK version 1.x.
Get-PfaAllProtectionGroupOffloadSnapshot
lists all of the Protection Group offloaded snapshots for the specified offload target.
# Lists all offloaded snapshots on "nfsTarget" for all protection groups. PS >Get-PfaAllProtectionGroupOffloadSnapshot -OffloadTargetName "nfsTarget" -Array "ArrayName"
Get-PfaAllVolumeOffloadSnapshot
lists all of the offloaded snapshots for the specified offload target.
# Lists all offloaded snapshots for all Volumes that are on "nfsTarget". PS >Get-PfaAllVolumeOfflaodSnapshot -Array "ArrayName" -OffloadTargetName "nfsTarget"
Get-PfaOffloadSnapshot
lists snapshots for the specified volume for the specified offload target.
PS >Get-PfaOffloadSnapshot -Array $Array -VolumeName "vol1" -OffloadTargetName "offTarget"
Get-PfaProtectionGroupOffloadSnapshot
lists snapshots for the specified Protection Group for the specified offload target.
PS >Get-PfaProtectionGroupOffloadSnapshot -Array $Array -OffloadTargetName "offTarget" -Name "protectionGroup1"
Restore-PfaAllVolumeOffloadSnapshot
will restore snapshots from an offload target.
# Restores snapshots from "offloadTarget" on to Array $Array for the specified snapshots "array2:snap2.vol1" PS >Restore-PfaAllVolumeOffloadSnapshot -Array $Array -Sources "array2:snap2.vol1" OffloadTargetName "offloadTarget"
Snapshot Statistics
You can retrieve the transfer statistics for snapshots of Volumes or Protection Groups. For volumes, use the Get-PfaVolumeSnapshotReplicationStatus
cmdlet, and for protection groups, use the Get-PfaProtectionGroupSnapshotReplicationStatus
cmdlet. Both cmdlets have similar parameters.
PS> Get-PfaVolumeSnapshotReplicationStatus -Array $FlashArray -Name 'DEMO-VOL1.TEST'
For Protection Group snapshots:
PS> Get-PfaProtectionGroupSnapshotReplicationStatus -Array $FlashArray -Name 'PGDEMO-VOL1.TEST'
There are also other cmdlets that can give you information on the status of snapshots. Please refer to the PowerShell Help context for more information on these cmdlets.
Get-PfaAllSnapshotSpaceMetrics
Get-PfaProtectionGroupSnapshotSpaceMetrics
Get-PfaSnapshotSpaceMetrics
Get-PfaTotalSnapshotSpaceMetrics