Version control your system configuration in /etc with SVK

Tagged:  •    •    •    •  

Sooner or later almost any Linux admin feel the need for a history of configuration changes. May it the X server configuration which got corrupted while you experimented with the Composite extension and OpenGL or may it the apache configuration you jumbled while updating the popular web server.

Gentoo Linux brings some powerful tool's (dispatch-conf, etc-update) out of the box to manage and update those configuration files. dispatch-conf is even able to store older versions inside of /etc/config-archive with RCS, but dealing with this ancient VCS is't that much fun and self written config files are not included by default.

SVK is the answer. SVK is a decentralized VCS, based on and using the database of Subversion. The advantages of using SVK for storing configuration files of a linux system compared to Subversion or CVS is, that it will not pollute the environment with additional directories (.svn or CVS) to store it's meta data. If you are familiar with Subversion, than you should feel very comfortable with SVK. Another feature is, that SVK can be used to mirror or syncronize other Subversion repositories. If you maintain more than one server, you could use SVK to merge/syncronize your configuration on a centralized Subversion repository. This way, all versions of all servers could be stored in a central place and it would be easy to merge changes from one server to another. But let's start with the simple howto.

First you need to create a repository called 'depot'.

svk depotmap --init

This will create the repository into ${HOME}/.svk. In our case in /root/.svk.
Now you can import the content of your /etc directory into the depot.

svk import --to-checkout //etc /etc

Because /etc contains security sensitive data, reducing the permissions of the repository is a good idea.

chmod -R ao-rwx /root/.svk

Now you can cd into /etc and may change some configuration files. When you are done you can review and commit your changes.

svk stat
SVKDIFF="colordiff -u" svk diff | less
svk commit -m "Description of the changes, e.g. System updated."

Some files which are generated by the system aren't good candidates for a VCS, e.g. /etc/ld.so.cache or /etc/adjtime. You can remove them from version control and add them to a list of files to be ignored by SVK.

cd /etc
svk rm -K ld.so.cache adjtime # remove from VC
EDITOR=/usr/bin/nano svk propedit svn:ignore # ignore by VC

So, now you have some kind of configuration assurance. Good other candidates for version control are located at

  • /root/bin
  • /boot/grub
  • /var/lib/portage
  • /var/db/...
  • ...

Trackback URL for this post:

http://lepetitfou.dyndns.org/home/trackback/60

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.
  • Internal paths in double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or relative path.
  • You may link to images on this site using a special syntax

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
4 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
Syndicate content