The snap delete command in NetApp is used to delete snapshot copies in a volume or SnapMirror relationship. Snapshots are point-in-time copies of data that can be used for backup and restoration purposes. The snap delete command allows you to delete snapshots that are no longer needed, freeing up space in the volume.
Snapshots are a key feature of NetApp’s SnapMirror technology for data replication and disaster recovery. When SnapMirror replicates data from a source volume to a destination, it also replicates the source volume’s snapshots. The snap delete command can be used on either the source or destination to delete unwanted snapshots.
Here are some key things to know about the snap delete command in NetApp:
What Snapshots Are
A snapshot is a read-only, point-in-time copy of a volume. It captures the state of the volume at the moment the snapshot is taken. Snapshots don’t consume any additional space when they are first created. As writes occur to the volume, any changed blocks are saved to the snapshot. This allows the snapshot to preserve the state of the volume when the snapshot was created.
Snapshots are useful for backup and recovery purposes. You can restore files or LUNs directly from a snapshot to recover from accidental deletions, corruption, or ransomware attacks. Snapshots can also be backed up to tape or the cloud.
Snapshot Consumption
Over time, a snapshot will consume space in the volume as changed blocks are written to it. The amount of space consumed depends on the change rate of the volume. More active volumes with a higher rate of change will consume more snapshot space.
Once snapshots start consuming space, it’s important to delete older snapshots that are no longer needed. This helps control snapshot consumption and frees up space in the volume.
Automated Snapshot Deletion
NetApp ONTAP offers automated snapshot deletion through SnapMirror policy rules and volume snapshot policies. This allows older snapshots to be deleted automatically on a schedule. For example, you could configure a rule to delete snapshots older than 7 days.
Manual snapshot deletion with the snap delete command provides an additional option for cleaning up unneeded snapshots.
Using the Snap Delete Command
Here are some examples of using the snap delete command:
Deleting a Single Snapshot
To delete a single snapshot, specify the snapshot name:
“`
snap delete mysnapshot
“`
Deleting Snapshot Range
You can delete a range of snapshots by snapshot name or creation timestamp:
“`
snap delete mysnapshot1-mysnapshot5
“`
“`
snap delete /vol/vol1/mysnapshot*
“`
“`
snap delete /vol/vol1 10/1-10/7
“`
Deleting All Snapshots
The following will delete all snapshots in a volume:
“`
snap delete /vol/vol1 *
“`
Deleting SnapMirror Snapshots
To delete snapshots on a SnapMirror destination volume:
“`
snap delete /vol/dst_vol src=src:src_vol
“`
You need to specify the source volume in a SnapMirror relationship when deleting snapshots on a destination.
Snap Delete Command Options
The snap delete command includes options to change its behavior:
-f Option
Force snapshot deletion even if it will break SnapMirror replication. Not recommended in most cases.
“`
snap delete -f mysnapshot
“`
-h Option
Halt future transfers from a snapshot. Allows the snapshot to be deleted after the current transfer finishes. Useful for deleting a SnapMirror snapshot that is still transferring.
“`
snap delete -h mysnapshot
“`
-w Option
Wait for the snapshot delete to finish before returning. Useful when scripting or automating snapshot deletion.
“`
snap delete -w mysnapshot
“`
-s Option
Delete the snapshot only after it has been synced to the SnapMirror destination. This avoids breaking replication.
“`
snap delete -s mysnapshot
“`
When to Use Snap Delete
Here are some common scenarios where cleaning up snapshots with snap delete is useful:
– Free up space when a volume is almost full
– Delete old snapshots that are no longer needed
– Clean up snapshots on a SnapMirror destination volume
– Remove snapshots created for temporary purposes like testing or troubleshooting
– Automate snapshot deletion on a schedule with scripts/workflows
In general, it’s a best practice to periodically delete old, unneeded snapshots. Keeping too many snapshots for extended periods can lead to performance issues and capacity problems.
Snap Delete Command Best Practices
Here are some best practices to follow when using the snap delete command:
– Use volume snapshot policies and SnapMirror rules to automatically delete old snapshots first. Use snap delete to supplement automated deletion.
– Avoid deleting snapshots that are still needed for backups or data recovery purposes.
– Don’t delete SnapMirror snapshots on a source volume unless they have been fully transferred to the destination. Use the `-s` option if needed.
– Monitor volume space and snapshot consumption levels so you can delete snapshots before volumes become full.
– For SnapMirror destinations, delete snapshots on the destination volume, not the source.
– When deleting a range of snapshots, start by deleting the oldest snapshots first.
– Consider halting future transfers from a snapshot (`-h` option) before deleting it to allow ongoing SnapMirror activity to finish.
Snap Delete Command Examples
Here are some more examples of using the snap delete command:
“`
snap delete /vol/vol1 hourly.2021-01-01*
“`
– Delete the hourly snapshots for January 1st, 2021.
“`
snap delete /vol/vol1 daily.2021-01-* -w
“`
– Delete all daily snapshots for January 2021 and wait for completion.
“`
snap delete -s /vol/dst_vol1 snapshots_for_testing
“`
– On a SnapMirror destination, delete snapshots named snapshots_for_testing after they have been replicated from the source.
“`
snap delete /vol/logs -h log_snapshot
“`
– Halt future transfers to log_snapshot on volume logs, then delete it.
“`
snap delete /vol/vol1> delete_logs.txt
“`
– Delete all snapshots on vol1 and output the deletion logs to a file.
Snapshot Consistency Groups
On ONTAP 9.5 and later, the snap delete command can also be used to delete consistency group snapshots.
Consistency groups take simultaneous snapshots across multiple volumes. To delete consistency group snapshots, specify the name of the consistency group rather than an individual snapshot name:
“`
snap delete cg_name
“`
This will delete all snapshots for the consistency group while maintaining write-order consistency across volumes.
Recovering Deleted Snapshots
If a snapshot is accidentally deleted, you may be able to recover it if volume backups exist:
– Restore the deleted snapshot from a vault or tape backup if applicable.
– For SnapMirror, break the SnapMirror relationship and make the destination writable to access the deleted snapshot.
– For SnapVault, use the snapvault restore command to restore a deleted snapshot from the SnapVault destination.
However, snapshot recovery is not always possible if backups don’t exist. That’s why it’s critical to follow best practices whenever using the snap delete command.
Conclusion
The snap delete command is a powerful tool for cleaning up unnecessary NetApp snapshots. By deleting old and unneeded snapshots, you can control snapshot consumption of space and improve volume performance.
Make sure to use snap delete cautiously and always follow NetApp best practices. Set up automatic deletion policies, test commands in pre-production, and have good backups. This allows you to reap the performance and efficiency benefits of snapshot deletion safely.