Home > OpenSolaris, Sys Admin > Updated snapadm.pl file for ZFS Snapshots

Updated snapadm.pl file for ZFS Snapshots

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.

  1. No comments yet.
  1. No trackbacks yet.