Array Performance and Data Protection
1748054 Members
4683 Online
108758 Solutions
New Discussion

Re: Delete all orphaned snapshots at once

 
SOLVED
Go to solution
HlynurK
Occasional Visitor

Re: Delete all orphaned snapshots at once

A very quick and dirty way to do this would be to run this from the command line:

snap --list --unmanaged --all |awk '{if ($4 == "No") {system(sprintf("snap --delete %s --vol %s", $2, $1))}}'

Be absolutely sure of what you are doing before running the command though and verify that the list "snap --list --unmanaged --all" is what you want to delete. There is no breaking out of it once you execute.

You can see the commands that will be run by running this:

snap --list --unmanaged --all |awk '{if ($4 == "No") {printf("snap --delete %s --vol %s\n", $2, $1)}}'

snowman386
Occasional Visitor

Re: Delete all orphaned snapshots at once

Just in case someone wanted the powershell to do this:

Get-NSVolume | foreach{ Get-NSSnapshot -vol_id $_.id| Where-Object {$_.is_unmanaged -eq $TRUE -and $_.online -eq $FALSE} foreach { Remove-NSSnapshot -id $_.id}