8

I want to use version control for config files in Ubuntu server.

But I found it's not easy to simply use git for the whole /etc directory, because many files don't need to be tracked and sometimes the system will write to files like logs which should be ignored.

Is there an application that can do this and make it easy? If it is based on git that is better.

9

The package etckeeper is specifically intended to manage your configuration files (located in the /etc directory) under a version control system(VCS).

What is etckeeper?

etckeeper is a collection of tools to let /etc be stored in a git, mercurial, darcs, or bzr repository. It hooks into apt (and other package managers) to automatically commit changes made to /etc during package upgrades.

How do I install etckeeper?

To install the package, click on the link provided below to install in Ubuntu Software Center(USC), or run sudo apt-get install etckeeper from the terminal(Ctrl-Alt-t).

etckeeper

How do I change etckeeper from the default VCS(bzr) to use git?

By default, etckeeper uses Bazaar(bzr) for version control management. This can be changed in the configuration file /etc/etckeeper/etckeeper.conf.

First, you will need to have git installed.

  • sudo apt-get install git
  • sudo apt-get install git-core

Now, you will need to edit your etckeeper.conf file to change your VCS. Here is what the first five lines of the default configuration should look like:

# The VCS to use.
# VCS="hg"
# VCS="git"
VCS="bzr"
# VCS="darcs"

This is the place in the configuration file to switch from using the default option of using bzr to using a git repository. Open a text editor (i.e. gksu gedit /etc/etc/keeper/etckeeper.conf) and change the file to look like this:

# The VCS to use.
# VCS="hg"
VCS="git"
# VCS="bzr"
# VCS="darcs"

Uncomment the line VCS="git" and comment out the line VCS="bzr"

Now, run sudo etckeeper init to initialize your repository.

As mentioned here:

This sets up version control for all files in /etc. You don't need to do anything else to manage etckeeper; you only need to interact with it when you want to do a version control operation, such as referring to older files. Files are automatically committed before and after each run of apt and every night (this is configurable).

Additional information on etckeeper:

See Ubuntu etckeeper documentation

also

Using etckeeper with git on Ubuntu

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.