Awhile back I wrote about performing an operation introduced in Purity 4.6 called protection group copy, which I really referred to as protection group recovery, which I think is maybe a more apt title.

Anyways, this feature is available in our REST API and our CLI (not yet in our GUI in a direct format) but is not yet built into our PowerShell SDK.  I have seen more than one request for information on how to do this, and it certainly can be done without our official SDK and this is through the good ol’ Invoke-RestMethod cmdlet built into PowerShell. I’ve spoken about using this many times, here and here.

Let’s walk through it specifically with protection group restore.

 

PowerShell Script

First off, I wrote a PowerShell script to do this. You can download it from GitHub here.

You need to enter in a few variables in the script:

  1. The FlashArray IP or FQDN
  2. FlashArray username/password
  3. The snapshot Point-In-Time you want to restore from
  4. The target protection group name
  5. Whether this is an overwrite operation, to overwrite make it equal to $false

variables

Most of this is straight forward, refer to the blog post linked above though for more information. A quick note on a snapshot name:

The snapshot is not an actual snapshot name–it is the point-in-time name of the desired protection group snapshots. So one of these names:

pitnames

Not one of these names:

snapshotnames

Because you are recovering all of the volumes. Not just one.

As for the actual powershell, it is really not too much code. Most of this is error handling really. The core protection group copy code is two parts:

Creating the REST body and making the REST call.

REST Body Creation

The REST body requires one or two parameters (depending on what you need to do), the source point-in-time and whether this operation should be overwriting existing volumes. In REST API 1.5, we allowed parameters to always be there, but can be true or false. Which makes things much easier. So I included both, and will change from true to false depending on the input. I store it in a hash table and then convert it to JSON, which is what the FlashArray REST service wants.

REST Call

Now to make the REST call itself. This is a simple Invoke-RestMethod command where you pass in that REST body JSON.

Note that it must be REST API 1.5 or later (so Purity 4.6 or later), this is when protection group recovery was introduced. The $Session is created from the earlier authentication steps. To understand how that is done, read this post.

That’s it!

Enjoy! This should be in our SDK officially at some point soon, but for now this should help!