Skip to main content
Pure Technical Services

How-To: Working with Snapshots and the Powershell SDK v1

Currently viewing public documentation. Please login to access the full scope of documentation.

 

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'

Creating a Volume from a Protection Group Snapshot

When creating new volumes (Copy Volume) from a Protection Group snapshot, the naming convention is the devil in the details. By not using the correct name of the Protection Group snapshot source, The creation of the volume will fail. Below is an example using the Pure Storage PowerShell SDK.

# Connect to FlashArray.
$f = New-PfaArray -EndPoint 10.0.0.1 -Credentials (Get-Credential) -IgnoreCertificateError

# OPTIONAL -- Used to illustrate all of the volume snapshots.
# Get all the volume snapshots, this will include PGroups. 
Get-PfaAllVolumeSnapshots -Array $f | ft -a

# Pick a specific Pgroup snapshot. Name of snapshot is FLASHARRAYNAME:PGROUPNAME.SNAPSHOT_NAME
$PgroupSnapSource = Get-PfaVolumeSnapshots -Array $f -volumename 'solutions-lab-bfs-405-c09-20:z-nightly-replica-to-PureTEC.157.arvnd-Boot-Lun-05'

# Create a volume from the Pgroup source.
New-PfaVolume -Array $f -Source $PgroupSnapSource.name -VolumeName 'barkz-test'

# Validate the volume has been created.
Get-PfaVolume -Array $f -Name 'barkz-test'

Output example:

source                                   serial                   created              name                                                                                        size
------                                   ------                   -------              ----                                                                                        ----                                       161061273600
old-Mike-Bootlun-04-2016tp5              73E940225A2A52BB0002CEF0 2020-08-04T23:47:25Z old-Mike-Bootlun-04-2016tp5.Mike-Bootlun-Rep                                        161061273600 
.......LOTS OF SNAPSHOTS......
Barkz-Bootlun-03-WS2016-DC-GUI-3         73E940225A2A52BB0003D19D 2020-10-19T17:39:00Z z-nightly-replica-to-PureTEC.157.Barkz-Bootlun-03-WS2016-DC-GUI-3                   161061273600
Barkz-Bootlun-04-WS2016-DC-GUI-4         73E940225A2A52BB0003D19E 2020-10-19T17:39:00Z z-nightly-replica-to-PureTEC.157.Barkz-Bootlun-04-WS2016-DC-GUI-4                   161061273600
Barkz-Bootlun-02-WS2016-DC-GUI-2         73E940225A2A52BB0003D19F 2020-10-19T17:39:00Z z-nightly-replica-to-PureTEC.157.Barkz-Bootlun-02-WS2016-DC-GUI-2                   161061273600
Barkz-Bootlun-05-WS2016-DC-GUI-5         73E940225A2A52BB0003D1A0 2020-10-19T17:39:00Z z-nightly-replica-to-PureTEC.157.Barkz-Bootlun-05-WS2016-DC-GUI-5                   161061273600

source  : arvnd-Boot-Lun-05
serial  : 73E940225A2A52BB0003D1A7
created : 2020-10-19T17:39:00Z
name    : barkz-test2
size    : 75161927680

name           : barkz-test2
created        : 2020-10-19T17:39:00Z
source         : arvnd-Boot-Lun-05
time_remaining : 
serial         : 73E940225A2A52BB0003D1A7
size           : 75161927680

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-PfaVolumeSnapshotReplicationStatuscmdlet, 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