Adding Etckeeper

Giang L. Nguyen

December 4, 2019

Backup of etc

On my nginx proxy-server, I wanted to take backup of my configuration and setup in case if the disk fails me. I considered using GIT only to push changes every day, week, etc., but there was to hard to maintain. I needed to make crontab to run a script and the script contained running git in differents folders. Then I found, ‘etckeeper’, which makes the whole process easier.

What is ‘etckeeper’ ?

‘Etckeeper’ is a revision tool who use git, mercurial, bazaar or darcs, I prefer git. It stores the metadata of the file and commit/pushes daily.

How to install and use it ?

Since I’m using ‘etckeeper’ under debian, the showcase will be shown using debian.

First of all, we need to install the app we are using, in our case, etckeeper and git.

  1. Update the system and install ‘etckeeper’ and ‘git’
sudo apt update && sudo apt install etckeeper git
  1. Change configuration for etckeeper
sudo vim /etc/etckeeper/etckeeper.conf
  1. Change your folder to /etc and start initate revision of the folder
cd /etc
sudo etckeeper init

If you haven’t setup git before, you should set your git config first. Using these commands, it’ll create a .gitconfig file in your home folder(~)

git config --global user.name "My Name"
git config --global user.email "my@email.name"
  1. You should check out the git status to see if you dont want to backup with git.
sudo etckeeper vcs status | less

When git is set, use etckeeper to commit.

sudo etckeeper commit "some comments"
  1. You can check out your commits, see and do changes by using the vcs
sudo etckeeper vcs log #checks the logs
sudo etckeeper vcs show <id> #checks commit changes
sudo etckeeper vcs diff <id>..<id2> #checks the different between the commits
sudo etckeeper vcs checkout <id2> #revokes the change of the commit
sudo etckeeper vcs checkout <id> /etc/<filename> #revokes changes of the commit on the file