mjt5282
Contributor
- Joined
- Mar 19, 2013
- Messages
- 139
When I upgraded from 9.10 to Corral, eventually I noticed a bunch of stale snapshots that were historically snapped pre-Corral, from 9.10 era FreeNAS. These ignored snapshots wasted disk space and would never be automatically excised, as far as I could tell, so I deleted the snaps manually.
Yesterday, I upgraded my backup server from FN Corral to FN 11-RC, and surmised that I would have to clean up the snapshots from Corral and start a new snapping "regime" on FN11. So, I wrote a simple bash script that iterates through the user datasets and deletes the "old-style" snapshots.
YMMV, no warranty implied or given :
There are some leftover snapshots under the root pool, /media, that I deleted manually.
But I hope others find this code useful.
Switch USERDATASETs with the actual names of your own datasets.
After you clean up your orphan snaps, please re-enable snapshots, they may save your butt and/or your job/your company's data at some point in the future!
Yesterday, I upgraded my backup server from FN Corral to FN 11-RC, and surmised that I would have to clean up the snapshots from Corral and start a new snapping "regime" on FN11. So, I wrote a simple bash script that iterates through the user datasets and deletes the "old-style" snapshots.
YMMV, no warranty implied or given :
Code:
#!/usr/bin/env bash # # mjt destroy useless Corral snapshots after upgrade to FN11 mjt 05/07/2017 # # # also have to as root : zfs destroy -r media/.vm_cache # delete root media snapshots (logic can't handle this) # for DATASET in USERDATASET1 UD2 UD3 UD4 .vm_cache .vm_cache/boot2docker .vm_cache/boot2docker/initrd .vm_cache/boot2docker/initrd_old0 .vm_cache/boot2docker/vmlinuz64 .vm_cache/boot2docker/vmlinuz64_old0 do echo "listing snaps for media/$DATASET" zfs list -H -o name -t snapshot | grep media/$DATASET done for DATASET in USERDATASET1 UD2 UD3 UD4 .vm_cache .vm_cache/boot2docker .vm_cache/boot2docker/initrd .vm_cache/boot2docker/initrd_old0 .vm_cache/boot2docker/vmlinuz64 .vm_cache/boot2docker/vmlinuz64_old0 do echo "destroying snaps for media/$DATASET" zfs list -H -o name -t snapshot | grep media/$DATASET | xargs -n1 zfs destroy done
There are some leftover snapshots under the root pool, /media, that I deleted manually.
But I hope others find this code useful.
Switch USERDATASETs with the actual names of your own datasets.
After you clean up your orphan snaps, please re-enable snapshots, they may save your butt and/or your job/your company's data at some point in the future!
Last edited by a moderator: