JAW Speak

Jonathan Andrew Wolter

Archive for the ‘servers’ tag

Recommended: etckeeper to keep all your server’s /etc in git (or bzr or hg)

with 7 comments

Reading time: 2 – 3 minutes

I’m using etckeeper to keep my /etc directory in version control (git).

When you make changes to a server, there are always risks. And even if you have a great backup strategy (I recommend backupninja), sometimes you change a config in the wrong way, which can ruin an otherwise great night. Why don’t we have an easy way to version control this very important configuration directory? (Ubuntu is working on it).

Here’s what $ sudo gitk will show you after a few changes in your /etc.
etckeeper with git

It’s no surprise that this comes from Joey Hess, who also wrote how to keep your life in svn. I was going to check into subversion all of /etc, but this has been a better experience so far: it has automatic hooks to do pre and post apt-get update commits. So you can more easily see what each package does to your configuration. Also, etckeeper takes care of permissions where svn can’t.

If you’re ready to install, here’s how you do it. I didn’t use the deb distribution because it is quite out of date, instead I pulled down the newest directly from Joey’s git repository.

$ sudo apt-get install git-core gitk
$ cd ~/
$ git://git.kitenet.net/etckeeper
$ cd etckeeper
( read the README and INSTALL files )
( possibly edit etckeeper.conf if you want to use bazaar or mecurial instead of git )
$ sudo make install  ( It's okay if it warns that bzr support not installed if you're not using it )
# sudo etckeeper init
$ cd /etc
$ sudo git status
$ sudo git commit -m "Initial checkin"

That’s it! Check out the README for day to day examples.

Whenever you use apt to install a program, it checks in any uncommitted changes, and then checks in the /etc after apt finishes. /etc is just a regular git repository (except for security permissions require using sudo), so you can also commit changes anytime you want.

Here’s another person’s take on etckeeper. New to Git? Check out Git for Computer Scientists.

Written by Jonathan

November 23rd, 2008 at 1:52 am

Posted in code

Tagged with ,