Subscribe
Accepted Solution

PS to show what vol does not have Snapshots enabled

Looking to powershell to find what volumes have Snapshots enabled and what snapshot policy is being used.  I know you can use Get-NcSnapshotPolicy to see the policies, but does not show which volumes it is applied to.

 

I have not been able to find a PS command that shows what volumes have snapshots enabled.  Get-NcSnapshot shows the current snapshots and outputs the volume, but i cant filter show volumes it is not enabled on.

Re: PS to show what vol does not have Snapshots enabled

Use Get-NcVolOption to check for the "nosnap" (it may have an underscore) option.

I will post an example when I'm no longer on mobile...

Andrew
If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: PS to show what vol does not have Snapshots enabled

Get the folllowing error:

 This cmdlet must be directed to a data vserver.  You are currently connected    |
| to the cluster admin vserver.  See the Toolkit web docs (Show-NcHelp) or online |
| help (Get-Help Connect-NcController -Examples) to learn more about directing    |
| Toolkit cmdlets to a cluster or data vserver as required by Data ONTAP.

 

Was hoping to run it at the cluster, so it would check all SVMs.

Re: PS to show what vol does not have Snapshots enabled

Still on mobile, so please forgive any errors (and this obviously isn't tested) as I'm pulling from memory...

Get-NcVol | ?{ ($_ | Get-NcVolOption -Hashtable).value.nosnap -eq "on" }

Andrew
If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: PS to show what vol does not have Snapshots enabled

That worked, but shows vault and mirror destination volumes.

Re: PS to show what vol does not have Snapshots enabled

Ok, back at a real computer...

 

There's a few things that we want to accomodate when checking for volumes which do not have snapshot protection:

 

  • Not a root volume...this is probably what was causing the errors to show up before
  • Not a data protection volume, which will exclude SnapMirror and SnapVault volumes
  • "nosnap" enabled, indicating snapshot policy has been disabled
  • or a Snap Policy of "none", indicating snaps are enabled, but no schedule is set

With all that in mind, we can use PowerShell to check for these things, filtering the things we want and don't want:

 

Get-NcVol | ?{ 
    # get non-root volumes
    $_.VolumeStateAttributes.IsNodeRoot -eq $false `
    -and
        # which are rw (this will exclude SnapMirror, etc.)
        $_.VolumeIdAttributes.Type -eq "rw" `
    -and 
    (
        # with "nosnap" turned on
        (($_ | Get-NcVolOption -Hashtable).value.nosnap -eq "on") `
        -or 
        # or with snapshot policy set to none
        ($_.VolumeSnapshotAttributes.SnapshotPolicy -eq "none") 
    )
}

Hope that helps.

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: PS to show what vol does not have Snapshots enabled

Also, to answer the second part of your original post, how to view the volume and it's snapshot policy:

 

Get-NcVol | Select Vserver,Name,@{N="Snapshot Policy"; E={ $_.VolumeSnapshotAttributes.SnapshotPolicy }}

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: PS to show what vol does not have Snapshots enabled

Both of them work great