Track changes to /etc (configuration files) with etckeeper
I'm currently setting up my new dedicated server and one of the first packages I've installed there has been etckeeper, to keep track of any changes to files in the etc (configuration) directory.
I've chosen to use "bzr". If you want to stick to the default (git), just leave out the bzr related stuff:
# Install etckeeper and bzr:
sudo apt-get install etckeeper bzr
# Read the fine documentation:
# Edit the config, chose the VCS to use:
sudo sensible-editor /etc/etckeeper/etckeeper.conf
# Init the repository:
sudo etckeeper init
# Verify that the file list is OK and commit:
sudo bzr commit -m "Initial checkin"
Now, whenever you use "apt" to install or remove programs, it will commit any changed files before and after the action (if there are any changes - not all packages install files into /etc).
Because "/etc" is now a regular repository, you can also manually commit any changes there, e.g. when editing some configuration file.
If you don't manually commit any changes, they will get picked up during the next run of apt automatically.
This is of course highly recommended for Desktop systems, too: you can always look up what changes to the system configuration have been done (including the exact time when you or somebody else has installed a particular package).
Give it a try, it won't hurt
If you had a choice between the two it seems more obvious to use git. (my 2 cents)
(Yes, commit/apt/commit is good).
I'm more used to bzr than to Git and I've helped out getting the bzr support for etckeeper into Ubuntu Hardy. "Eat your own dogfood" etc.
Yes, it might be a good idea to put more than /etc under version control. I can imagine that this becomes possible with etckeeper someday, but it makes not a lot of sense for the whole file system. You rarely want to put really everything under version control and you can already manually create a repo in "/", if you want to.
It should be also possible to integrate this into the workflow when using apt-get to install or remove packages, or just add your own hook command for apt/dpkg to call your custom commit command.
sudo etckeeper pre-commit
before you commit when you are using bzr. I'm not sure if this needs to be done before every commit, or just the first, but that could be a problem. I'm not sure how the automatic commits after apt are supposed to work under bzr if you manually have to "pre-commit" before each commit. (Note: I'd prefer to use bzr myself, so I'd like to see any issues resolved). The relevant lines from the README:
Warning: bazaar cannot support running etckeeper's pre-commit hook. To
ensure that all file metadata is stored in bzr, you have to manually
run "etckeeper pre-commit" before committing to bazaar.
The pre-commit hook gets run automatically for the apt hook, but you only have to manually call "etckeeper pre-commit", when committing changes yourself (e.g. you've edited a file and want to commit that - and it has special permissions).
There is already a etckeeper with full bzr pre-commit support, but it did not make it for Hardy (requires bzr 1.4).
Now I understand that etckeeper adds also versioning of file metadata. Is there a way to install etckeeper but keep my previous history of /etc?
That's what I did on my desktop machine, too. You can install etckeeper and it will re-use the existing .bzr repository (remember to configure "VCS=bzr").
This is very cool indeed!!
thanks for making a receipe that is so simple!
The apt hook works fine, pre-commit and all?
There is some more info here:
just going though your HowTo and I neede to use sudo to commit.
So instead of
bzr commit -m "Initial checkin"
I needed to
sudo bzr commit -m "Initial checkin"
Else I would get an arrno 13 from bzr.
Thanks for this post which led me to etckeeper.