ZFS filesystem snapshot delete utility for users and root.

Purge ZFS snapshots


Why and what is this script for ?
This script is used to delete several snapshot on ZFS filesystem. It easily allow (the administrator or the user) to delete (some or all) snapshots of the current or specified user(s). It allow normal user to only delete their own snapshot while admin can delete any users's snapshot. Users can free they own diskspace when snapshot are made automatically. This script is safe as it will ask for confirmation before deleting any snapshots (Unless otherwise specified).

Technically this script list the snapshots of a given user. It will list availble snapshot to delete and can allow you to select which one you want to delete (using -grep option), then (after confirmation) it will simply do a "zfs destroy snapshot mypool/user99@auto_snapshot" for each snapshot found.

Why create snapshot?
Snapshot are very useful. It allows users to have access to their full account like it was at the snapshot time. Snapshot are very quick to take and they can be made automatically by a cron job with this snapshotZFS script. A more complete script with similar function can now be found on github.com for ZFS on Linux project.

Why delete snapshot?
An issue can occur with snapshots when users have a disk quota set and when creating several snapshot automatically (via a cron job) or not, it can then consume all user's disk space. This tools simply provide a secure way to delete those snapshots while allowing the simple user to regain control over it's account. It can either be run by root or by any normal user allowed by root with sudo.

It can also be used by a normal user with sudo installed. However in user mode it will only allow current user to delete it's own snapshot and no one else'. A username is not required in user mode because all username are ignored and only the current username is taken.

To allow all users to run purgezfs, add purgezfs to any folder in the user's global path (example: /usr/local/bin/) and add this line to "/etc/sudoers" file.

More info?
ZFS was originally found on Solaris but now can be found on several OS using OpenZFS and Linux with ZFS on Linux project and FreeBSD.

You can find demo about ZFS on the net.: ZFS Demos....

Latest Features :

Download purgeZFS here :

This is the script available freely for download. You are welcome to donate. :-)

Exemples :

This is an example of ZFS filesystem with snapshots. Giving this kind of ZFS examples the fallowing script will show how to purge some ZFS snapshots.

This is some examples of what the script can do and how to do it.

Limitations, bugs or to do...

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see http://www.gnu.org/licenses/.
  1. Distribute and use under GPL licenses
  2. No known bug.
  3. Send email for request, suggestions or appreciation to lepage at grm polymtl ca

Web page version history

  • Full Changelogs
  • 1 mai 2018: text update
    12 sept 2016: version 2.62
    17 aout 2016: version 2.61 and text update
    17 mars 2014: version 2.52 and text update
    29 mai 2013: version 2.51 and text update
    4 mars 2013: version 2.5 and comments
    12 sept 2008: version 2.2 and info update
    9 juin 2008: version 2.0 and GPL
    20 mai 2008: Web page update + v1.3
    12 mai 2008: Web page update + v.1.2
    01 mai 2008: first page web + v.1.0
    01 avril 2008: Project startup, how to purge zfs snapshot...

    About the othor Réjean Lepage M.Sc, ©, Dernières modifications Tue, 04 April 2023, 15:03