Keeping track of system configuration (backup the other way)

If you are administering you own server, you may have already solving problem how to return to previous configuration, because now you have made some ‘important’ changes and this changes work perfect, but nothing else works 😉 And now you pray: ‘if i ever could return to my configuration done X days ago’.

You can solve this with good backup mechanism, but this was not good enough for me. I’m foremost a developer and i like the way versioning system works and so I’ve started it to use for automatic backing up my server(s) configuration and also some important installed software.

How easy setup a version server (that can be placed on remote server or where ever you want) and then start add new items to you repository, then commit and voilà, you have you first server configuration backup. With a few lines of scripting you can automatize this thing and force everyday changes to be commited automatically if you (or someone) forgot to make an individual commit.

My setup:
I use subversion for this, but you can choose whatever versioning system you like. Centralized are a bit better for doing this IMHO.

Simple how-to begin:

  • svn co <path to your repository> /
  • svn add -N /  # -N is for not to recurse all subdirs
  • svn add -N /etc
  • svn add /etc/ssh /etc/hosts /etc/….
  • svn ci /

And thats all (I presume you already have subversion repository created), with svn add command you add new ‘monitored’ items. svn ci commits changes. You should read some simple how-to about subversion, there is myriad of it out there.

Pros:

  • very easy to setup, (almost) no configuration required
  • you can describe your changes, in commit messages one can note what this commit does
  • you can track file renames (i don’t think any backup software can do this)
  • with software like redmine you can monitor changes, get informed by email about it, make bug & feature management and so on…
  • if you have more servers (i.e. production and testing), with a little effort you can make configuration management and test new configuration on testing servers and than copy ‘stable’ configurations to production server(s) very easily
  • multiple servers can have configuration from one repository using i.e. read-only access (no scp/rsync) – this needs some scripting, but it is easy
  • with cron and few lines of scripts system can automatically backup itself
  • proven software, with big surrounding community, good support and tons of add-on tools
  • always doing incremental backup, and storing only differences not everything

Cons:

  • you may have to use version systems command for file management (like svn del, svn mv). This can be annoying, and some versioning systems sometimes doesn’t handle renaming of files very well (like subversion, but you can use git from Linus), but how often you do something like that ?
  • no other comes me on my mind

PS: And don’t forget to backup your backup repository 😉