marcin(a)studio4plus.com

File History with ZFS Snapshots How-To

To implement a simple file history two aspects have to be taken care of:
  1. snapshot creation,
  2. archival file version access.

Automatic Snapshot Creation

Auto-save-like functionality requires snapshots to be created often (1-10 minutes seems ok for /home) so an automated solution for creating new snapshots and removing stale ones is required.

You may roll out your own, use Ralf S. Engelschall's tools or download my zfs-snapshot-mgmt script.

After the installation the configuration file has to be created. At first it will be enough to just copy the file /usr/local/etc/zfs-snapshot-mgmt.conf.sample to /usr/local/etc/zfs-snapshot-mgmt.conf and edit it as necessary.
Detailed information is included in the documentation:

man zfs-snapshot-mgmt

The last step is to add the zfs-snapshot-mgmt script to be run from cron, e.g. (all on one line, two > characters):

echo '*/1 * * * * root /usr/local/bin/zfs-snapshot-mgmt' >> /etc/crontab

From now on the program will be run every minute and will create and remove snapshots according to its configuration.

Accessing Archival File Versions

To access snapshot versions of your files from Nautilus download the gsnapper.rb script and save it in the /home/<your_username>/.gnome2/nautilus-scripts/ directory.

The file has to be made executable:

chmod +x gsnapper.rb

You may also rename it so that it has a nice name in the menu:

mv gsnapper.rb "File History"

The script will be accessible in the file menu under the right mouse button, in "Scripts".

2010-03-20