Last Updated: February 25, 2016
· viccuad

backup server config with a repository

Have you ever modified a batch of your awesome server config files just to find that nothing works any more?
are you keeping your server options on a paper block or on another machine?
go the easy way! and backup all of your changes for the foreseeable future!

Existing tools

The easiest option to use etckeeper:
etckeeper allows /etc be stored in a git, mercurial, darcs, or bzr repository. It hooks into apt (and other package managers including yum and pacman-g2) to automatically commit changes made to /etc during package upgrades. It tracks file metadata that revison control systems do not normally support, but that is important for /etc, such as the permissions of /etc/shadow.
etckeeper it's packaged in Debian, Ubuntu, Fedora, etc.

for the diy-ers. e.g: with git

If you want to feel the bolts and cogs, here is an easy way of doing this with git awesomeness:

cd /etc
git init
git add hostname
git commit -m "Initial commit." hostname
git branch stock  //for stock config
git branch play   //for playing config

//one example of use: add a config to the stock branch
git checkout stock
apt-get install squid
git add squid/squid.conf
git commit -m "Adding stock config file." squid/squid.conf
git checkout master

//other example of use: play with configs
git checkout play
git commit -m "Partially finished experiment." squid/squid.conf
git checkout master
git merge play // when the experiment is working and we want to keep it

* this can be extended to the whole /. git should just work with binary files, see the chapter of this [book][book].
* without configuring setgitperms, git does not record filesystem thingies:
- file groups
- file owners
- file permissions (other than "is this executable")
- extended attributes

other options could be: