NetApp PowerShell Toolkit 101: Volume Snapshots

Snapshots are one of the core features of ONTAP, and something that many, many people rely on every day to protect their data from accidental (or malicious…) deletion and corruption. The NetApp PowerShell Toolkit can help us to manage the configuration of snapshot policies, the application of those policies to volumes, and creating/deleting/reverting snapshots too.

This post will cover:

  • Snapshots
    • Management
    • Reporting
    • Snap Reserve
  • Snapshot Policies
  • Snapshot Autodelete
  • Recovering Data

Snapshots

Managing Snapshots

  • Show snaps for a volume
  • Create a snapshot

  • Delete a snapshot

Snapshot Reporting

  • Show volumes with no snapshot protection
    I originally created this snippet as a response to this NetApp Communities question. It returns non-root data volumes (not data protection volumes) which have the volume option nosnap enabled or have a snapshot policy of none.

  • Show the oldest snapshot for a volume

  • Show snapshots more than X days old

  • Show the cumulative snapshot usage for one (or more) volumes

  • Show volumes with a dependent/busy snapshot

Snap Reserve

Snap reserve is the amount of space in the volume which has been set aside for snapshot data…i.e. the data which is changed. The size of the snapshot is “contained” in this capacity, and not deducted from the available space in the volume.

  • Show snap reserve for a volume

  • Set the snap reserve for a volume

  • Show volumes with no snap reserve

  • Show volumes with snap reserve > X percent
  • Show volumes with snapshots exceeding the snap reserve

Managing Snapshot Policies

The snapshot policy is what determines when the ONTAP system will automatically create a snapshot and how long to retain it.

  • Show snapshot policy for all volumes

  • Show volumes with a particular policy

  • Create a policy with a custom schedule

  • Change the snapshot policy for a volume

Managing Snapshot AutoDelete

Snapshot AutoDelete is a protection mechanism, meant to prevent your volume from running out of space from oversized snapshots. There are a number of settings associated with AutoDelete. The names used for the ClusterShell and from the PowerShell toolkit are slightly different, I’ve noted the differences below.

  • CLI = Enabled, PSTK = statetrue/false (CLI) or on/off (PSTK), this indicates whether AutoDelete is enabled for the volume.
  • Commitment – How aggressive should AutoDelete be when removing snapshots? try = only delete snapshots which are not “in use” or locked by FlexClone, SnapMirror, etc. disrupt = will allow AutoDelete to remove data protection (SnapMirror, etc.) snapshots. destroy = will allow AutoDelete to remove snapshots used by FlexClone.
  • Trigger – What causes the AutoDelete action to kick off? volume = when volume capacity crosses the (configurable) threshold. snap_reserve = when the snap reserve is nearly full. space_reserve = when the reserved space in the volume is nearly full.
  • Target Free Space – AutoDelete will stop deleting snapshots when free space reaches this percentage.
  • Delete Ordernewest_first or oldest_first, the order which snapshots will be deleted. Generally speaking, oldest_first will result in the most space reclaimed.
  • Defer Deletescheduled = delete snapshots taken by the snapshot policy last. user_created = delete user created snapshots last. prefix = delete snapshots with the specified prefix last. none = don’t defer any, just delete in the specified delete order.
  • CLI = Defer Delete Prefix, PSTK = prefix – The prefix used when the defer delete value is prefix.
  • Destroy List – This list of services which can be destroyed if the backing snapshot is removed. This is the corollary for the commitment value of destroy The default is none, which is the safest option. Refer to the documentation for specifics.

With an understanding of the options, let’s look at how to query and modify AutoDelete settings.

  • Show the AutoDelete policy for a volume

  • Show all volumes with autodelete enabled/disabled

  • Enable/disable for a volume

  • Set multiple options for a volume

Recovering Data

Revert a snapshot

Restore a file using FlexClone

I originally posted a version of this to the NetApp Communities site. This will create a FlexClone of the file from a snapshot into the current file system. Note that this is not the same thing as a single file snap restore, which uses the Restore-NcSnapshotFile cmdlet.

3 thoughts on “NetApp PowerShell Toolkit 101: Volume Snapshots

  1. I have multiple cloned volumes on a windows clustered environment. How can i give them a unique volume id? I am using Set-NcLunSignature to change the LUN Id, but the volume id remains the same.

Leave a Reply

1e7854ddb66bcdd19a1b5e03eb0920ff[[[[[[[[[[[[[[[