My systems tend to live for a long time with very frequent updates. By this, I mean that I don't reinstall the system, but continually upgrade the same Linux installation. While I apply upgrades to patches frequently (daily), this also applies to major distribution upgrades as well.

Performing in-place distribution upgrades is easier in some distributions than others - as with most things in life there are tradeoffs, so distributions likes raw Debian, or LMDE (Linux Mint Debian Edition) are always rolling upgrades, but tend to lag far behind Ubuntu or other mainline distributions (Linux Mint, Arch, Gentoo etc). On the flip-side, there are distributions who strongly discourage doing in-place upgrades, recommending users back-up and restore the system for each upgrade.

While Linux Mint is in that latter category, it's actually quite easy to do an in-place upgrade without losing anything. Although some people have reported issues doing so, I've never had any insurmountable issues with doing it. In fact, one of my computers last had a full install of Linux Mint 11, and is now running Linux Mint 15, having been upgraded each time.

In fact, in some cases doing upgrades have given me greater stability and options than a fresh install, such as when there was a kernel 3.8 issue in Linux Mint 15 that would have prevented boot, but instead I was able to simply boot under an older 3.5 kernel from Linux Mint 14, which I used until a newer kernel was available with the issues fixed.

Wait, isn't this a blog about etckeeper? Oh, right! :-) All of the discussion above is a great reason for why you might want to keep your /etc configuration files under version control. As packages are upgraded, or as you change configurations over time, you can easily diff configurations. And if you do a reinstall type upgrade, you can save off your entire /etc directory along with the version history, for comparison.

Whenever a package has an updated configuration file it's a bit less stressful to just answer "Yes, overwrite my customized configuration with the package maintainers version". Although it always saved back-up files previously, it wasn't always easy to find all the files related to a specific upgrade. With etckeeper, it's trivial - just diff the commits!

Setting up etckeeper is easy, and in it's simplest form you don't have to manage it at all - as you apt-get (or use aptitude, or other higher level package manager utilities), your /etc configuration will be automatically versioned. I recommend git for the version control system (VCS), which is what is in the examples below.
  • Install etckeeper (and git if you don't already have it):

 $ sudo apt-get install git etckeeper 
  • Update /etc/etckeeper/etckeeper.conf, commenting all VCS lines except git:
 $ sudo vi /etc/etckeeper/etckeeper.conf 
  • The first few lines of that file should look like:
 # The VCS to use. 
  • And finally, initialize the etckeeper repository:
 $ sudo etckeeper init         
 $ sudo etckeeper commit "initial version" 
  • This will create an initial commit of all your configuration files as they are now.
For the simplest use-case, that's all there is to using etckeeper! Whenever you do any system changes through the apt-get package manager (directly or indirectly), etckeeper will automatically get executed to version your configuration files in /etc before and after any package changes are applied to your system.

You can also explicitly commit changes when you manual change configuration files, and use the commit command to track them. See the manpages and the etckeeper site for more information. 

And finally, because this just uses git under the covers, you can use git commands to diff versions, etc - just cd to /etc and use git as root.