Add etckeeper
Overview
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 update
Add
git
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 "dfdpublic@wildtechgarden.ca" # 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 configureduser.name
anduser.email
of the original user (e.g. thesudo
-ing user for non-root adminsudo
-ing toroot
) to set the author and committer fields, so you need to set at leastuser.email
anduser.name
for each user that will be usingetckeeper
, even if throughsudo
).
Install and configure etckeeper
Install etckeeper
apk add etckeeper
Edit
/etc/etckeeper/etckeeper.conf
so 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
AVOID_DAILY_AUTOCOMMITS=1
Just avoids a warning that doesn’t help us much
AVOID_SPECIAL_FILE_WARNING=1
This will require to use
etckeeper commit "A message about the commit"
before installing with APK, if there are changes to/etc
you have not already committed. This makes the logs more useful than the automatic messages that let one be too careless.AVOID_COMMIT_BEFORE_INSTALL=1
Add root’s
.gitconfig
to LBU backupslbu add /root/.gitconfig
If your non-root admin user(s) home(s) are not on persistent storage, add those
.gitconfig
to LBU as well.
Commit your changes
Commit changes to
etckeeper
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).
lbu commit