Microsoft Virtualization Discussions

PS to show what vol does not have Snapshots enabled

jhawkroche
12,513 Views

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.

1 ACCEPTED SOLUTION

asulliva
12,502 Views
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.

View solution in original post

8 REPLIES 8

asulliva
12,507 Views
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.

jhawkroche
12,504 Views

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.

asulliva
12,503 Views
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.

jhawkroche
12,499 Views

That worked, but shows vault and mirror destination volumes.

asulliva
12,422 Views

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.

jhawkroche
12,359 Views

Both of them work great

asulliva
12,421 Views

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.

markey164
9,815 Views

@asulliva wrote:

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


Just stumbled across this thread as i was looking for the same thing. The above command works great.....except it truncates some of myoutput  like this:

 

vserve... abVolume1  vserver1__standard_po...

 

How can I tidy up the output so i can see the full text?

 

TIA

Public