howto

etckeeper

etckeeper is a collection of tools to let /etc be stored in a git, mercurial, bazaar or darcs repository. It hooks into apt to automatically commit changes made to /etc during package upgrades. It tracks file metadata that git does not normally support, but that is important for /etc, such as the permissions of /etc/shadow. It’s quite modular and configurable, while also being simple to use if you understand the basics of working with version control.

Install

# EPEL repo is required
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

# installing etckeeper package
yum install etckeeper -y

Configure

# Initialize git repo for /etc
etckeeper init

# Review the files added
cd /etc
git status

# Execute initial commit
git commit -m "initial checkin"

# pack git repo to save a lot of space	
git gc

Manage

# Viewing log
cd /etc && git log

# Restoring /etc copy elsewhere
mkdir /my/workdir
cd /my/workdir
chmod 700 .
git clone root@<hostname>:/etc
cd etc
etckeeper init -d .
chmod 755 ..

Add remote backup server and gitlist web frontend (optional)

  • Please see Gitlist setup howto part from here: https://support.opennodecloud.com/wiki/doku.php?id=usrdoc:os:rancid#installing_gitlist

  • NB! Make sure your backup/admsrv can do passwordless login by ssh key to target host!

# Create backup location
mkdir -p /backup/etckeeper
chmod 750 /backup/etckeeper
chgrp apache /backup/etckeeper

# Clone the repo from node to backup/admsrv
cd /backup/etckeeper
git clone root@<hostname>:/etc/ <hostname>
chmod 750 /backup/etckeeper/<hostname>
chgrp apache /backup/etckeeper/<hostname>

# Add etckeeper repositories path to Gitlist config 
nano -w /usr/share/gitlist/config.ini
--- ADD ---
repositories[] = '/backup/etckeeper/' ;
--- ADD ---