»

Etckeeper

By jbayer - Last updated: Tuesday, April 10, 2012 - Save & Share - 2 Comments

We’ve been using etckeeper lately to back up our /etc directories with a version control system..  I was dissatisfied with it because it was only designed to backup /etc or a specific directory.  It did not have the capability to backup multiple directories, such as

/etc, /usr/local/etc, /var/bind

I’ve been corresponding with the author, Joey Hess, and just sent him a patch which adds the ability to backup multiple directories.  I’ve included the patch below so you can apply it yourself.

This is against version 0.62, which is the current version as of this date.

Once applied, you need to edit the /etc/etckeeper/etckeeper.conf, uncomment and edit the ETCKEEPER_DIR line to specify whatever directories you wish to backup.  Then run “etckeeper init” to initialize the version control directories.


#-------------------- etckeeper.conf patch ------------------------------
*** etckeeper.conf.orig 2012-03-13 15:03:42.000000000 -0400
--- etckeeper.conf 2012-04-10 15:54:12.000000000 -0400
***************
*** 4,9 ****
--- 4,18 ----
 #VCS="bzr"
 #VCS="darcs"
+ # List of directories which etckeeper will be preserving. Do NOT use
+ for /home backups, etc # These are examples of what can be done. If
+ nothing specified, then /etc is # used as a default # Overridden by
+ the -d option # ETCKEEPER_DIR="/etc /var/bind"
+ # ETCKEEPER_DIR="/etc /usr/local/etc"
+ # ETCKEEPER_DIR="/etc /usr/local"
+ # ETCKEEPER_DIR="/etc"
+
 # Options passed to git commit when run by etckeeper.
 GIT_COMMIT_OPTIONS=""
#-------------------- /usr/bin/etckeeper patch -------------------------------
*** etckeeper.orig 2012-02-17 21:52:50.000000000 -0500
--- etckeeper 2012-04-10 15:46:55.000000000 -0400
***************
*** 84,104 ****
 fi
 fi
! if [ -z "$ETCKEEPER_DIR" ]; then
! ETCKEEPER_DIR=/etc
! fi
! cd "$ETCKEEPER_DIR"
! export ETCKEEPER_DIR
! lsscripts() {
! perl -e '
! $dir=shift;
! print join "\n", grep { ! -d $_ && -x $_ }
! grep /^\Q$dir\/\E[-a-zA-Z0-9]+$/,
! glob "$dir/*";
! ' "$1"
! }
! for script in $(lsscripts "$ETCKEEPER_CONF_DIR/$command.d"); do
! "$script" "$@"
 done
--- 84,109 ----
 fi
 fi
! KEEPDIRS="$ETCKEEPER_DIR"
! for keepdir in $KEEPDIRS; do
! ETCKEEPER_DIR=$keepdir
!
! if [ -z "$ETCKEEPER_DIR" ]; then
! ETCKEEPER_DIR=/etc
! fi
! cd "$ETCKEEPER_DIR"
! export ETCKEEPER_DIR
! lsscripts() {
! perl -e '
! $dir=shift;
! print join "\n", grep { ! -d $_ && -x $_ }
! grep /^\Q$dir\/\E[-a-zA-Z0-9]+$/,
! glob "$dir/*";
! ' "$1"
! }
! for script in $(lsscripts "$ETCKEEPER_CONF_DIR/$command.d"); do
! "$script" "$@"
! done
 done
# --------------------------- end of patch ------------------------------------------
Posted in Administration, Open Source • • Top Of Page
1,034 views

2 Responses to “Etckeeper”

Comment from zoredache
Time April 17, 2012 at 6:19 pm

So if I want to do an etckeeper init after the fact, I have to initialize the repo with `etckeeper init -d path`, then add the new directory to the etckeeper.conf? It seems like adding a directory to the conf file and then running etckeeper init would result in an error.

Since it appears that you are depending on many repositories, it seems like your logs would get a bit weird. If you make some change in /etc and /var/bind/example.org.dns, then then do a commit, it sure seems like you would expect that to be a single operation handled in a single repository.

Comment from jbayer
Time April 24, 2012 at 2:46 pm

Because of the way that git and mercurial work, they are stored in different repositories. This is a result of the revision control system, not etckeeper.

Write a comment

asd