Workflow: ZFS snapshot-ed file versions to tar and git archives with httm
For most non-programming tasks, no one actually wants to work within a git repo. While git repos offer many benefits, including interoperating with the git ecosystem, most of the time, they're just too heavy weight for most system administration tasks.
Imagine you could have many of those same benefits, but only when you need them.
Maybe you already know what to do when you want to send all snapshot-ed versions of your syslog
via email:
httm -n /var/log/syslog | tar -zcvf all-versions-syslog.tar.gz -T -
But imagine something a little more difficult. Imagine you've misconfigured your sysctl.conf
and you have just the pal you know knows how to fix it, but she's a half-a-world away. You think -- who wants to dig through 10+ file versions to identify the source of the error? Wouldn't it be nice if she could see your changes as you made them incrementally?
Use httm
and this just works:
# create variable for file name
file="/etc/sysctl.conf"
# create git repo
mkdir ./archive-git; cd ./archive-git; git init
# copy each file version to repo and commit after each copy
for version in $(httm -n $file); do
cp "$version" ./
git add "./$(basename $version)"
git commit -m "$(stat -c %y $version)"
done
# create git tar.gz archive in the parent directory
git archive --format=tar.gz -o "../archive-git-$(basename $file).tar.gz" master; cd ../
And to view the your changes incrementally:
tar zxvf archive-git-sysctl.conf.tar.gz
cd ./archive-git
git log -p
Is there a Unix-y workflow you'd like to see covered by httm
? Let me know!