Over the last couple days I’ve briefly talked about revisioning configs and making your home directory portable. It seems to have stirred up a bit of discussion over at Matt Simmons Standalone Sysadmin, and Hugh Browns mentioned he uses mercurial for this task.. As I noted in the post about managing /etc with version control I do revision my home directory, or at least pieces of it.
I consider this to be a different problem than making my environment portable. For example I want my configs to have a full revision history, even things like my ssh config or my private keys. I want that history as a backup, I do not want to distribute all of that information to other machines. gibak is a great wrapper for git to help with this.
Installation is not hard but you will need to install a few dependencies.
aptitude install ocaml omake git-core git clone http://eigenclass.org/repos/git/gibak/.git/ cd gibak omake cp find-git-files ~/bin cp find-git-repos ~/bin cp gibak ~/bin cp ometastore ~/bin
Now that its installed you just need to initialize your git repo, make adjustments to your .gitignore (you probably don’t want _everything_ in your repo).
gibak init vim ~/.gitignore gibak commit
I don’t have everything in my home directory revisioned. Mainly I revision configuration files and my Documents. Here is what my .gitignore looks like.
# I am selective about what I want to revision, you may not want this. /* # You probably want to ignore all the "dot" files in your home # directory, since they mostly contain local application state data. /.* # but... some dot files you probably do *not* want ignored are # listed here: !/.bash* !/.gnupg !/.ssh !/.vimrc !/.mutt /.mutt/profile.d/*/cache !/.gitignore !/.todocycle !/Documents
Now depending on what files you want in your repo and if they change frequently or not you may want to have a cron job to automatically commit changes to your repo. I would suggest an entry similar to this.
0 0 * * * gibak commit "Automatic Commit - $(date +%m.%d.%Y)"
To manually commit changes just run gibak commit after making changes.
Now you can deal with your revisioned files just like any other git repo. You can clone it to a remote location to back it up, revert commits or whatever else suits your fancy.