In Part 1 of creating volumes from Protection Group (PGroup) sources I discussed how to get a specific snapshot to use for a disaster recovery (DR) restore. In the case of having a more automated DR workflow retrieving the latest snapshot from the PGroup is a key requirement.
The below PowerShell script example removes the manual task of picking a specific PGroup snapshot like in Part 1.
1 2 3 4 5 6 7 8 9 10 |
# Connect to FlashArray. $f = New-PfaArray -EndPoint 10.0.0.1 -Credentials (Get-Credential) -IgnoreCertificateError # Get latest PGroup Snapshots. $psoPGroup = Get-PfaAllVolumeSnapshots -Array $f | where {$_.Source -like “*Barkz-Bootlun-06-WS2016-DC-GUI-6*” -and $_.Name -like “*z-nightly-replica-to-PureTEC*”} ForEach ($PGroupSnapshot in $psoPGroup) { If ([DateTime]($PGroupSnapshot.created) -gt (get-date).addHours(-8)) { Write-Host $PGroupSnapshot.name ” — “ $PGroupSnapshot.created } } |
Note: You will notice that the Get-PfaAllVolumeSnapshots does not return a PSObject and the “created” field is returned as a string. Using [DateTime] I convert the string to a datetime and then compare that to get snapshots >8hrs.
Output:
1 2 |
z–nightly–replica–to–PureTEC.158.Barkz–Bootlun–06–WS2016–DC–GUI–6 — 2017–10–20T15:49:00Z z–nightly–replica–to–PureTEC.159.Barkz–Bootlun–06–WS2016–DC–GUI–6 — 2017–10–20T17:39:00Z |
Thanks,
Barkz