While the LBU mechanism with backups allows restoring to previous state it lacks commented history. Done right, etckeeper will lead to a better record of what changes you made to the configuration and why, which improves your ability to recreate what you did, as well as understand why you did what you did. It also makes it easier to revert broken changes in a more granular fashion.
Configure Git for the root user
This is known as a ‘global’ configuration as ’local’ configuration refers to per-repository configuration.
The following command should be run as root (e.g. prefixed with
sudo or doas when in your admin non-root user account).
Make sure apk package list is up to date
apk add git
Execute the following commands as root, adjusted to suit you and your preferences
git config --global init.defaultBranch main git config --global user.name "root@yourserver (Daniel F. Dickinson)" # Obviously you want your name here git config --global user.email "email@example.com" # Obviously you want your email here git config --global pull.ff only git config --global core.fileMode true git config --global core.eol lf git config --global core.autocrlf false git config --global core.editor nano
Repeat for your non-root admin user (without
sudo), adjusted to suit your preferences. (Etckeeper uses the configured
user.emailof the original user (e.g. the
sudo-ing user for non-root admin
root) to set the author and committer fields, so you need to set at least
user.namefor each user that will be using
etckeeper, even if through
Install and configure etckeeper
apk add etckeeper
/etc/etckeeper/etckeeper.confso it has the following snippets in place of the defaults for these items:
Don’t autocommit every day; this just creates noise if we are doing things right
Just avoids a warning that doesn’t help us much
This will require to use
etckeeper commit "A message about the commit"before installing with APK, if there are changes to
/etcyou have not already committed. This makes the logs more useful than the automatic messages that let one be too careless.
.gitconfigto LBU backups
lbu add /root/.gitconfig
If your non-root admin user(s) home(s) are not on persistent storage, add those
.gitconfigto LBU as well.
Commit your changes
Commit changes to
etckeeper commit "Configure etckeeper"
Commit the changes to LBU (not strictly necessary if you will be doing other changes before committing; just don’t forget to commit to LBU).