Track config changes with etckeeper

Description

This page covers how to install and set up revision control and tracking for your server configuration directory using a program called etckeeper.

Prerequisites

  • An recent Ubuntu server.
  • etckeeper (see below)

Installation

To install the etckeeper run the following command.
sudo apt-get install etckeeper

Configuration

On Ubuntu, etckeeper is configured by default to use GIT. If you wish to change this, open the configuration file.
sudo nano /etc/etckeeper/etckeeper.conf
Edit the VCS line and select one of the other available choices.
# The VCS to use.
#VCS="hg"
VCS="git"
#VCS="bzr"
#VCS="darcs"
If you change the VCS from the default, you will need to initialize etckeeper
cd /etc
sudo etckeeper init 
Now each time you install new software, etckeeper will automatically update and commit the changes. If you make any manual changes to files in /etc, then you should commit the change using etckeeper as per below.
sudo etckeeper commit "Describe the reason for the change"

Testing

If you want to see the results of the last commit enter the following.
sudo etckeeper vcs show
If you want to see a log of previous commits enter the following.
sudo etckeeper vcs log
If you want to see the results of a specific commit, you can choose one of the commit ID's from the commit log and issue the show command.
sudo etckeeper vcs show cbc5b1b7