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.

This entry was posted in OpenSolaris, Sys Admin and tagged , , . Bookmark the permalink.

2 Responses to Updated snapadm.pl file for ZFS Snapshots

  1. Pingback: snapadm.pl – FIX | UNIX Admin

  2. Pingback: ZFS Rolling Snapshots – Cron this script. | UNIX Admin

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>