Hire me if you like: blake.irvin@gmail.com

Monday, March 10, 2008

Remove Old ZFS Snapshots

I used this command recently to cull old zfs snapshots (I was changing the naming convention used by timf's auto-snapshot service to use _'s instead of :'s as a separator, since samba doesn't like :'s). The command should be on one line, backslashes are used to show that line breaks are not returns. 'grep -v' is used to avoid deleting certain snapshot types (-v is the reverse-matching flag).

for snapshot in `zfs list -H -t snapshot \
| grep -v daily | grep -v weekly \
| grep -v monthly | awk '{print $1}'`; \
do zfs destroy $snapshot; done

No comments: