In my post OpenSolaris Backup Solution with Rsync and ZFS Snapshots I provided a link to a script from Sun – snapadm.pl. I found a bug where if you were using the recursive function then the old snapshots would never be destroyed as they were incorrectly named.
I have updated the snapadm.pl file contained in my post and have also provided a download link here.
Download:
Read on for more details:
diff snapadm.pl_.txt snapadm.pl_1.txt 181c181 < my $result = `/sbin/zfs snapshot -r $SnapFS@_$class_name_$ztimestamp`; --- > my $result = `/sbin/zfs snapshot -r $SnapFS@$class_name_$ztimestamp`;
The snapshot being taken for the recursive option was incorrectly adding an _ (underscore) to the classname. This meant that when the isExpired method performs a regex search on the snapshot name then no match returns and therefore no snapshot gets destroyed.
Pingback: snapadm.pl – FIX | UNIX Admin
Pingback: ZFS Rolling Snapshots – Cron this script. | UNIX Admin