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.

3 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

  3. Carsten says:

    Hi
    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.
    Thanks
    Carsten

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>