bartman's blog

etc snapshots with git

bartman

I got this idea from a blog posting a few months back. I think the guy was using darcs. Unfortunately, I was unable to find the reference to link to him.

Anyway, here is how you can track your /etc directory with git, and have apt update it automatically each time a package is installed.

The following steps require root access:

… and you’re done.

Note that the chmod og-rwx /etc/.git step is very important. Your /etc/.git directory should only be accessible to root. If not, it’s as good as giving everyone access to your /etc/shadow and other secrets that hide in /etc. Should you clone this repository to another box, you have to make sure that the same precautions are taken.

Now when you install a package, it will be tracked in the git repository.

    # apt-get install mercurial
    ...
    Created commit daa7de7264b65cd073a1ef0f75ba50aa488d5af2
     3 files changed, 409 insertions(+), 0 deletions(-)
     create mode 100644 bash_completion.d/mercurial
     create mode 100644 mercurial/hgrc
     create mode 100644 mercurial/hgrc.d/hgext.rc

You can see what changed…

    # git whatchanged -1
    commit daa7de7264b65cd073a1ef0f75ba50aa488d5af2
    Author: Bart Trojanowski <bart@jukie.net>
    Date:   Mon Mar 12 16:09:18 2007 -0400

        snapshot after: apt-get install mercurial

    :000000 100644 0000000... a7f4740... A  bash_completion.d/mercurial
    :000000 100644 0000000... dfc3400... A  mercurial/hgrc
    :000000 100644 0000000... 8f2d526... A  mercurial/hgrc.d/hgext.rc

Update…

Only two days after writing the original posting I got two replies. In one, Michael Prokop told me that he had ported my procedure to use mercurial. Rock on!

Later still I was notified by Yannick Gingras that he also tackled the etc tracking with mercurial task.

And lastly, it should be noted that debian now has an etckeeper that trackes /etc in git.

Tags: