Anyone who’s tried to remove Snapmirror relationships using the NetApp commandline knows how painful it is. Recently, I had a need to remove all snapmirror relationships from a number of NetApp storage systems and figured I’d play with NetApp’s PowerShell toolkit to see if I could semi-automate the process.

Below are some notes and some code snippets that may help if you ever need to do this yourself.

Environment Setup

If you haven’t got them already, download and install PowerShell 4.0 and the latest NetApp DATAONTAP Powershell toolkit

Open up PowerShell and run:

If you get an error about not being able to execute scripts, run:

Scenario

I have a number of storage systems, each with many snapmirror relationships with other storage systems. All storage systems will accept the same credentials. I want to remove all snapmirror relationships associated with the destination storage systems.

We’ll be using the following NetApp cmdlets:

To find out more about these use:

Scripting

First, you may wish to setup an authentication token. I like using this method as it’s relatively secure, and doesn’t involve embedding passwords into scripts

This asks for the credentials via an authentication popup, and stores those credentials in a new variable called $authentication that we can pass to the -Credential parameter when connecting to a storage system later on. Lovely.

Let’s connect to our destination storage system (that is, the one whose snapmirror relationships we want to kill with fire remove cleanly)

OK, now, we need to get a list of all the snapmirror relationships on the storage system and pass those results to the command that will quiesce all of those relationships

This may take a while.

Once it’s done, this next code snippet will get that same list of snapmirror relationships and then:

  1. Grab the object in the Source field and use Regular Expressions to isolate the source storage system and put it in its own variable
  2. Pass that source storage system variable as well as the Source and Destination details to the Remove-NaSnapmirror cmdlet
  3. Use the authentication token to authenticate against the source storage system (in order to release the snapmirror relationship)

For every relationship to be removed, you’ll be asked if that’s really what you want to do. For safety’s sake, leave that in place. If you’re feeling cavalier, you can automatically say yes to that prompt by replacing the above Remove-NaSnapmirror line with:

Your mileage may vary. Let me know how you get on!

Written by Phil Wiffen

Phil is an IT Professional working in Cambridge, England. He generally blogs about useful solutions that he comes across in his work/play.

Leave a Reply

Your email address will not be published. Required fields are marked *