Interactive, file-level Time Machine-like tool for ZFS/btrfs/nilfs2 (and even Time Machine and Restic backups!)
Interactive, file-level Time Machine-like tool for ZFS/btrfs/nilfs2 (and even Time Machine and Restic backups!)
httmThe dream of a CLI Time Machine is still alive with httm.
httm prints the size, date and corresponding locations of available unique versions (deduplicated by modify time and size) of files residing on snapshots, but can also be used interactively to select and restore files, even snapshot mounts by file! httm might change the way you use snapshots (because ZFS/BTRFS/NILFS2 aren't designed to find unique file versions) or the Time Machine concept (because httm is very fast!).
httm boasts an array of seductive features, like:
rsync-ed non-ZFS/BTRFS/NILFS2/APFS local datasets (like ext4, XFS, or NTFS), not just ZFS/BTRFS/NILFS2 snapshots and TM backups.diff compare to the live version)rsync, httm can determine whether file is unique based solely on metadata, or use checksumsls colors from your environmentmultiple, single, single-with-snap,..., etc.)httm: ounce, bowie, equine, and nicotineUse in combination with you favorite shell's hot keys for even more fun.
Inspired by the findoid script, fzf, skim and many zsh key bindings.
For Debian-based distributions (like Ubuntu), I maintain an (unsupported) personal package archive, or PPA. See the linked repository.
For Debian-based and Redhat-based Linux distributions (like Ubuntu or Fedora, etc.), also check the tagged releases for native packages for your distribution. For Redhat-based Linux distributions, you may need to use the --replacefiles option when installing via rpm -i, see the linked issue.
You may also create and install your own native package from the latest sources, for Debian-based and Redhat-based Linux distributions, like so:
#!/bin/bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo install cargo-deb
git clone https://github.com/kimono-koans/httm.git
cd ./httm/; cargo deb
# to install on a Debian/Ubuntu-based system
dpkg -i ./target/debian/httm_*.deb
# or convert to RPM
alien -r ./target/debian/httm_*.deb
# and install on a Redhat-based system
rpm -i --replacefiles ./httm_*.rpmFor Arch-based Linux distributions, you can create and install your own native package from the latest sources, like so:
#!/bin/bash
# warning: this is only an example PKGBUILD
# you may need to edit the example, as needed, to conform to the latest release
wget https://raw.githubusercontent.com/kimono-koans/httm/master/packaging/arch/example/PKGBUILD
makepkg -siFor MacOS users, a user from the community (very exciting) has posted a formulae for Homebrew.
Installation via a package is suggested for support purposes, but, those wild childs, who perhaps can't stop (or won't stop), they can install by piping a script to bash:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/kimono-koans/httm/master/packaging/install-from-source.bash)"For those who simply wish to build httm incrementally themselves, the project contains only a few components:
The httm executable. To build and install:
#!/bin/bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
latest="(wget -nv -O - "https://api.github.com/repos/kimono-koans/httm/releases/latest" 2>/dev/null | grep tag_name | cut -d: -f2 | cut -d'"' -f2)"
# cargo-install places a release binary in your $HOME/.cargo/bin, however,
# you may wish to: cp $HOME/.cargo/bin/httm /usr/local/bin/httm; cargo uninstall httm
cargo install --locked --git https://github.com/kimono-koans/httm.git --tag "$latest"The optional zsh hot-key bindings: Use ESC+s to select snapshots filenames to be dropped to your command line (for instance after the cat command), or use ESC+m to browse for all of a file's snapshots. After you install the httm binary, to copy the hot key script to your home directory, and source that script within your .zshrc:
➜ httm --install-zsh-hot-keysThe optional man page: cargo has no native facilities for man page installation (though it may in the future!). You can use manpath to see the various directories your system uses and decide which directory works best for you. To install, just copy it to a directory in your man path, like so:
➜ cp ./httm/httm.1 /usr/local/share/man/man1/The optional scripts. See script usage below, in the Example Usage section, or follow the links (ounce, bowie, equine, and nicotine), for more information. To install, just copy it to a directory in your path, like so:
#!/bin/bash
cp ./httm/scripts/ounce.bash /usr/local/bin/ounce
# bowie is "required" for the default/best "--preview" behavior
cp ./httm/scripts/bowie.bash /usr/local/bin/bowie
# equine is "required" for Time Machine support on MacOS
cp ./httm/scripts/equine.bash /usr/local/bin/equine
cp ./httm/scripts/nicotine.bash /usr/local/bin/nicotine
chmod +x /usr/local/bin/bowie /usr/local/bin/ounce /usr/local/bin/equine /usr/local/bin/nicotineRight now, you will probably need to use a Unix-ish-y Rust-supported platform to build and install (that is: only Linux, FreeBSD, and MacOS are known to work). Note, your platform does not need to support ZFS/BTRFS/NILFS2 snapshots or TM backups to use httm. And there is no fundamental reason a non-interactive Windows version of httm could not be built, as it once did build, but Windows platform support is not a priority for me right now. Contributions from users are, of course, very welcome.
On FreeBSD, after a fresh minimal install, the interactive modes may not render properly, see the linked issue for the fix.
On some Linux distributions, which include old versions of libc, cargo may require building with musl instead, see the linked issue.
Note: Users may need to use sudo (or equivalent) to view versions on BTRFS or NILFS2 datasets, or Restic repositories, as BTRFS or NILFS2 snapshots or Restic repositories may require root permissions in order to be visible. Restic and Time Machine backups also require an additional flag, see further discussion of Restic --alt-store in the below.
Like other UNIX utilities (such as cat, uniq, sort), if you include no path/s as arguments, then httm will pause waiting for input on stdin:
# Press CTRL+C to send a SIGINT and quit the program
➜ httm
# Pipe output of find command to httm
➜ find . -maxdepth 1 | httmPrint all unique versions of your history file:
➜ httm ~/.histfilePrint all unique versions of your history file, as formatted JSON:
➜ httm --json ~/.histfileBrowse all files in your home directory, recursively, and view unique versions on local snapshots:
➜ httm -b -R ~Print all files on snapshots deleted from your home directory, recursive:
➜ httm -d -R ~Browse all files deleted from your home directory, recursively, and view unique versions on all local and alternative replicated dataset snapshots:
➜ httm -d=only -b -a -R ~Print all files on snapshots deleted from your home directory, recursive, newline delimited, piped to a text file:
# pseudo live file versions
➜ httm -d -n -R --no-snap ~ > pseudo-live-versions.txt
# unique snapshot versions
➜ httm -d -n -R --no-live ~ > deleted-unique-versions.txtBrowse all files in your home directory, recursively, and view unique versions on local snapshots, to select and ultimately restore to its original location, in overwrite mode:
➜ httm -r=overwrite -R ~Browse all files in your home directory, recursively, and view unique versions on local snapshots, to select and ultimately restore to your working directory, in "guard" mode, which overwrites and guards any restore action with a pre-recovery ZFS snapshot:
➜ printf "
# export a default httm restore mode
export HTTM_RESTORE_MODE=\"guard\"" >> ~/.zshenv
➜ httm -r -R ~View unique versions of a file for recovery (shortcut, no need to browse a directory):
➜ httm -r /var/log/samba/log.smbdhttm is also a good Unix citizen, which means -- you should use the other Unix utilities to organize your queries how you like them. find and awk are especially useful here:
…View bowie-formatted diff of each unique snapshot of ~/.zshrc against the live file version (requires the bowie script be installed):
➜ httm --preview -s ~/.zshrcView cat output of each unique snapshot of ~/.zshrc:
➜ httm --preview="cat {snap_file}" -s ~/.zshrcRecover the last-in-time unique file version (shortcut, no need to browse a directory or select from among other unique versions):
➜ httm -l -r /var/log/samba/log.smbdSnapshot the dataset upon which /etc/samba/smb.conf is located:
➜ sudo httm -S /etc/samba/smb.confBrowse all files, recursively, in a folder backed up via rsync to a remote share, and view unique versions on remote snapshots directly (only available for BTRFS Snapper and ZFS datasets). (Note: Remember to make ZFS snapshots visible in your smb.conf with zfsacl:expose_snapdir=True).
# mount the share
➜ open smb://<your name>@<your remote share>.local/Home
# execute httm
➜ httm -b -R /Volumes/HomeBrowse all files, recursively, in your MacOS home directory backed up via rsync to a ZFS or BTRFS Snapper remote share, shared via smbd, and view unique versions on remote snapshots. Note: The di
No open issues yet, or sync has not completed.