etckeeper allows the contents of
/etc to be stored in a Version Control System (VCS) repository. It integrates with APT and automatically commits changes to
/etc when packages are installed or upgraded. Placing
/etc under version control is considered an industry best practice, and the goal of etckeeper is to make this process as painless as possible.
Install etckeeper by entering the following in a terminal:
sudo apt install etckeeper
The main configuration file,
/etc/etckeeper/etckeeper.conf, is fairly simple. The main option is which VCS to use and by default etckeeper is configured to use Bazaar. The repository is automatically initialized (and committed for the first time) during package installation. It is possible to undo this by entering the following command:
sudo etckeeper uninit
By default, etckeeper will commit uncommitted changes made to /etc daily. This can be disabled using the AVOID_DAILY_AUTOCOMMITS configuration option. It will also automatically commit changes before and after package installation. For a more precise tracking of changes, it is recommended to commit your changes manually, together with a commit message, using:
sudo etckeeper commit "..Reason for configuration change.."
Using bzr’s VCS commands you can view log information:
sudo bzr log /etc/passwd
To demonstrate the integration with the package management system (APT), install postfix:
sudo apt install postfix
When the installation is finished, all the postfix configuration files should be committed to the repository:
Committing to: /etc/ added aliases.db modified group modified group- modified gshadow modified gshadow- modified passwd modified passwd- added postfix added resolvconf added rsyslog.d modified shadow modified shadow- added init.d/postfix added network/if-down.d/postfix added network/if-up.d/postfix added postfix/dynamicmaps.cf added postfix/main.cf added postfix/master.cf added postfix/post-install added postfix/postfix-files added postfix/postfix-script added postfix/sasl added ppp/ip-down.d added ppp/ip-down.d/postfix added ppp/ip-up.d/postfix added rc0.d/K20postfix added rc1.d/K20postfix added rc2.d/S20postfix added rc3.d/S20postfix added rc4.d/S20postfix added rc5.d/S20postfix added rc6.d/K20postfix added resolvconf/update-libc.d added resolvconf/update-libc.d/postfix added rsyslog.d/postfix.conf added ufw/applications.d/postfix Committed revision 2.
For an example of how etckeeper tracks manual changes, add new a host to
/etc/hosts. Using bzr you can see which files have been modified:
sudo bzr status /etc/ modified: hosts
Now commit the changes:
sudo etckeeper commit "added new host"
For more information on bzr see ???.