blog/ Setting up etckeeper

etckeeper is a tool, packaged in Debian, that lets you track revisions to /etc in a Git repository. Here's how to install and configure it.

You can download etckeeper from the url above, but it's probably best to get it from a Debian repository. Since I run etch on my server, that repository would have to be To add it:

  1. Add deb etch-backports main contrib non-free to your /etc/apt/sources.list

  2. Run: # wget -O - | apt-key add - to add the key for that archive, and then run # apt-get update

Once you have available, you can now install etckeeper:

 # apt-get install etckeeper git-core metastore -t etch-backports

A git of at least 1.5.4 is needed, which isn't available in stock etch, so it's also needed from etckeeper also requires a number of other dependencies, including python, and mercurial (even though we won't be using it).

Once installed, etckeeper is not automatically configured, so let's do that. First, we need to initialize it:

 # cd /etc
 # etckeeper init
 # git add .
 # etckeeper commit 'Initial commit'
 # git gc 

This adds the contents of /etc, recursively, and packs the git repository.

The etckeeper package configures itself to run on pre- and post-install when apt or dpkg install a package, so automatic changes to /etc will be tracked automatically.

Manual changes can be tracked with regular git commands after editing. For example:

 # vim /etc/resolv.conf
 # git commit -a -m 'Added new nameserver entry'