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