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 [command_options_and_arguments]
PARAMETERS
init
Initializes the /etc directory for etckeeper. This sets up the chosen VCS (e.g., Git repository) and performs the initial commit of all existing files in /etc.
commit
Manually commits all uncommitted changes in /etc to the VCS. An optional message can be provided for the commit.
status
Shows the current status of the /etc repository, similar to git status, indicating modified, added, or deleted files.
log
Displays the commit history of the /etc repository, showing past changes and their messages.
vcs
Allows direct execution of VCS commands within the /etc repository. For example, 'etckeeper vcs git diff' will run git diff in the /etc directory.
uninit
Removes etckeeper's setup from the /etc directory, reverting it to a state without VCS tracking.
pre-install
A hook executed by package managers (e.g., APT, DNF) before installing or upgrading packages. It commits the current state of /etc.
post-install
A hook executed by package managers after installing, upgrading, or removing packages. It commits the new state of /etc.
DESCRIPTION
etckeeper is a collection of tools that allows the /etc directory to be stored in a version control system (VCS) such as Git, Mercurial, Bazaar, or Darcs.
Its primary purpose is to help system administrators track changes to configuration files, making it easy to review modifications, revert to previous states, and audit system configurations. etckeeper achieves this by automatically committing changes to the chosen VCS, especially when triggered by package manager operations (like installing, upgrading, or removing packages). It also includes a daily cron job to commit any uncommitted changes.
Beyond simple file tracking, etckeeper handles crucial aspects of /etc, including preserving file permissions, managing symlinks, and ensuring that empty directories are also tracked by the VCS. This robust approach makes it an invaluable tool for maintaining the integrity and traceability of system configurations.
CAVEATS
VCS Dependency: etckeeper requires a supported Version Control System (like Git) to be installed and available on the system.
Initial Setup: It must be initialized with 'etckeeper init' before it starts tracking changes.
Not a Full Backup: While it tracks configuration files, it is not a substitute for a comprehensive system backup solution. It focuses solely on the /etc directory.
Permission Handling: Although it attempts to preserve file permissions, some VCS systems might require specific configurations or manual intervention for complex permission setups.
INTEGRATION WITH PACKAGE MANAGERS
etckeeper integrates seamlessly with common Linux package managers such as APT (Debian/Ubuntu), DNF/YUM (Fedora/RHEL), and Pacman (Arch Linux). It does this by installing hooks (scripts) that automatically trigger a commit of the /etc directory state both before and after package operations. This ensures that every configuration change related to software installation or removal is captured in the VCS history.
SUPPORTED VCS SYSTEMS
etckeeper supports several popular Version Control Systems, including:
Git (recommended and default)
Mercurial (Hg)
Bazaar (Bzr)
Darcs
The choice of VCS is typically made during the initial 'etckeeper init' command, or configured in /etc/etckeeper/etckeeper.conf.
HISTORY
etckeeper was initially developed by Joey Hess, with its first stable release appearing around 2007. The project aimed to address a common pain point for system administrators: tracking changes to the crucial /etc directory, especially in environments where frequent package installations and updates could lead to configuration drift. Its innovative approach of integrating with package manager hooks and leveraging existing VCS tools quickly made it a popular solution for robust configuration management.