etckeeper on custom directory

I have been reading about etckeeper, but I can't work out if you can use it on any other directories other than /etc.

There seems to be no reference to /etc in any configuration file (that I can find) so I assue this is hard coded and you can't chose directories to monitor. Is this true? I'd like to also have it manage /opt. Can this be done?


Solution 1:

It is right there in the man page.

  • Create a directory /foo
  • Initialize with etckeeper: etckeeper init -d /foo
  • Commit apply commits to the directory: etckeeper commit -d /foo 'message'

But as ErikA mentioned you could just as easily use git or your favorite DVCS directly.

Solution 2:

Etckeeper is merely a wrapper for mercurial or git. It provides some nice hooks into package management tools to automatically grab a commit after updates, and optionally on a schedule. This additional functionality is most likely not needed outside of /etc.

Depending on your needs, I'd just use vanilla git (or any other version control tool you're familiar with). If needed, schedule regular commits via cron or as part of your application deployment process.

Solution 3:

If you don't want to all the time provide "-d" you can put line:

ETCKEEPER_DIR=/opt

into /etc/etckeeper/etckeeper.conf.
It's not in man, but it can be inferred from etckeeper script.