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.
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.
3 replies on “Updated snapadm.pl file for ZFS Snapshots”
snapadm.pl is a very handy tool. Do you know if it is still necessary to stop snapadm.pl doing snapshots, if a scrub is running (or to stop scrubing before)? At least in Sol10 u8 I’ve found no information about this topic in the manpage of ‘zfs’ , ‘zpool’. My tests on a Sol10u8 machine shows no ‘restarting’ of the scrub process if I do snapshot in the middle.