ounce (codename: 'dimebag'): Dynamic File-Level ZFS Snapshots
ounce (codename: "dimebag") is a wrapper script for httm which give you no mental overhead, non-periodic dynamic snapshots.
On Hacker News, there was an article about how NILFS seems to "take" continuous snapshots. In addition to checkpoints, one can stop a NILFS filesystem from garbage collecting, roll back to a point in time, and recover a file that was once there. And, this seems great, if you can take the performance hit of a log-structured file system (which is substantial).
But perhaps like my boy Ben Franklin (or was it my mother, or Ben Franklin's mother?) said "an ounce of prevention is worth a pound of cure"? Why not just take a snapshot before you do something silly?
For awhile, one has been able to just feed httm
file names and have it figure out which dataset those files resided on. Like so:
➜ printf "/var/log/syslog\n/etc/passwd\n" | sudo httm --snap
httm took a snapshot named: rpool/var/log@snap_2022-10-21-08:57:04_httmSnapFileMount
httm took a snapshot named: rpool@snap_2022-10-21-08:57:04_httmSnapFileMount
But I don't know about you, I don't usually feed file names into a pipe before I type Name of $EDITOR redacted to prevent flame war
or rm
?
When I type:
# nano used here to frustrate just you
➜ nano /etc/samba/smb.conf
If there is not a snapshot that matches the live version, I would like my computer to snapshot /etc/samba/smb.conf
before I do something stupid. ounce
does this for me and now for you.
# why do you hate nano so much?
➜ ounce nano /etc/samba/smb.conf
ounce
knows that it's smart and I'm dumb, and sees that I just edited /etc/samba/smb.conf
a few short minutes ago and takes a snapshot before I edit the file again because it wants me to have snapshots of all my file changes. You can check:
➜ httm /etc/samba/smb.conf
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
Tue Aug 09 16:46:14 2022 17.6 KiB "/.zfs/snapshot/autosnap_2022-10-19_20:00:22_hourly/etc/samba/smb.conf"
Fri Oct 21 09:11:17 2022 17.6 KiB "/.zfs/snapshot/snap_2022-10-21-09:11:18_httmSnapFileMount/etc/samba/smb.conf"
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
Fri Oct 21 09:11:25 2022 17.6 KiB "/etc/samba/smb.conf"
─────────────────────────────────────────────────────────────────────────────────────────────────────────────
For more fun, simply alias to the commands you make modifications with:
# don't get triggered but...
alias nano="ounce nano"
alias rm="ounce rm"
Now available in httm
version 0.16.1.