etckeeper
Track /etc configuration directory in version control
TLDR
Set up a Git repo and perform various setup tasks (run from /etc)
Commit all changes in /etc
Run arbitrary Git commands
Check if there are uncommitted changes (only returns an exit code)
Destroy existing repo and stop tracking changes
SYNOPSIS
etckeeper [options] command
PARAMETERS
init
Initializes the version control repository in `/etc`.
commit
Commits any pending changes in `/etc` to the version control repository.
vcs
Sets the version control system to use (git, mercurial, bzr, darcs).
avoid-commit-before-upgrade
Prevents pre-upgrade commit which will allow APT to continue even when there are uncommitted files
pre-install
Hook executed before a package is installed.
post-install
Hook executed after a package is installed.
pre-upgrade
Hook executed before a package is upgraded.
post-upgrade
Hook executed after a package is upgraded.
pre-remove
Hook executed before a package is removed.
post-remove
Hook executed after a package is removed.
DESCRIPTION
Etckeeper is a tool that automates the process of storing the `/etc` directory in a version control system, typically Git, Mercurial, Bazaar, or Darcs. It's designed to run transparently in the background, automatically committing changes to the repository as they occur. This allows system administrators to easily track modifications made to system configuration files, revert to previous states, and audit changes. Etckeeper integrates well with package management systems like APT and DPKG, automatically committing changes made during package installations, upgrades, and removals. It uses hooks in APT and DPKG to automatically commit changes, ensuring that configuration changes made by package managers are tracked. It provides a record of every alteration, which is invaluable for debugging, auditing, and disaster recovery. Using etckeeper significantly improves system manageability, especially in complex environments or where changes are made frequently. Changes are tracked without manual intervention making the process of rolling back accidental changes easy and painless. Etckeeper can be configured with daily cron jobs or systemd timers for periodic backups.
CAVEATS
Etckeeper relies on consistent access to the version control system. If the repository becomes corrupted or unavailable, it could disrupt system updates or prevent changes from being tracked.
It also requires proper configuration to ensure that sensitive data (e.g., passwords) are not committed to the repository.
CONFIGURATION
Etckeeper's behavior is controlled by the `/etc/etckeeper/etckeeper.conf` file. This file allows you to specify the version control system to use, set commit messages, and configure other options.
The `GIT_COMMIT_OPTIONS` parameter controls the options used when committing via git.
USAGE EXAMPLES
Initialize the repository: etckeeper init
Commit current changes: etckeeper commit "My commit message"
Change the VCS to git: etckeeper vcs git
HISTORY
Etckeeper was created to address the need for automated version control of system configuration files, specifically within the `/etc` directory. Its development was driven by the desire to provide a seamless and transparent way to track changes made to system configurations, especially in environments where frequent updates and modifications occur.
The initial implementation focused on integrating with package management systems like APT and DPKG, automatically committing changes made during package installations and removals.
Over time, Etckeeper has been expanded to support various version control systems, including Git, Mercurial, Bazaar, and Darcs, catering to diverse user preferences and existing infrastructure. The development of etckeeper is still going on, as of writing.