| File | Date | Author | Commit |
|---|---|---|---|
| CLAUDE.md | 2025-12-30 | twm | [r9] Update documentation for sorting optimization a... |
| README.md | 2025-12-30 | twm | [r9] Update documentation for sorting optimization a... |
| zfs-snapshot-extract.sh | 2025-12-30 | twm | [r8] Add date jump feature to navigate to snapshots ... |
A bash script that helps you recover older versions of files from ZFS snapshots with an interactive interface.
stat, date, basename, mkdir, cpbash
chmod +x zfs-snapshot-extract.shbash
sudo mv zfs-snapshot-extract.sh /usr/local/bin/zfs-snapshot-extractNavigate to the root of a ZFS dataset mountpoint and run:
./zfs-snapshot-extract.sh <relative-file-path>
To see help information:
./zfs-snapshot-extract.sh --help
# or
./zfs-snapshot-extract.sh -h
cd /tank/mydata
./zfs-snapshot-extract.sh documents/report.txt
This will:
.zfs/snapshot/documents/report.txt~/report.txt_<timestamp>/report.txtZFS Snapshot Extractor
=====================
File: documents/report.txt
Found 12 distinct version(s)
Showing snapshots 1-5 of 12:
# Snapshot Modified Size
---- ------------------------------ ------------------------- ----------
1 autosnap_2024-01-15_14:00 2024-01-15 13:45:22 256KB
2 autosnap_2024-01-14_14:00 2024-01-14 16:20:15 245KB
3 autosnap_2024-01-12_14:00 2024-01-12 09:30:45 238KB
4 autosnap_2024-01-10_14:00 2024-01-10 11:15:33 220KB
5 autosnap_2024-01-08_14:00 2024-01-08 14:22:10 215KB
1-5 - Select snapshot by number
(N)ext, (D)ate, (E)xit
Enter your choice:
The interactive menu supports:
Both uppercase and lowercase letters are accepted.
Press D to jump to snapshots from a specific date/time. The script accepts various date formats:
2024-01-15 or 2024-01-15 14:3015 Jan 2024 or 15 Jan 2024 14:3001/15/2024The display will center around the snapshot closest to your specified date/time.
After recovering a file, you'll be prompted to press (E)xit or any other key to continue. This allows you to easily recover multiple versions when you're not sure which one you need.
When you select a snapshot, the file is copied to:
~/[filename]_[ISO-datetime]/[filename]
Example:
~/report.txt_20240115T134522/report.txt
.zfs/snapshot exists)select for numbered menu navigation.zfs is accessible).zfs snapshots are visible (ZFS snapdir property set to visible)zfs get snapdir <dataset>snapdir=hidden, set it to visible: zfs set snapdir=visible <dataset>chmod +x zfs-snapshot-extract.shwhich bashbash --versionThis project is provided as-is for free use and modification.
Feel free to submit issues or pull requests for improvements.