Is it possible to use etckeeper with a single shared git repository?

I noticed that several people have recommended using etckeeper to apply version control to my /etc directory.

It appears to me that the default install puts a repository on the same machine as the /etc you are trying to manage. This works fine for version control, but doesn’t give the added benefit of making an off-server backup of the files – or allow me to duplicate portions of /etc from one source machine to another.

Is it possible to share a single git repository on a central admin machine, so that etckeeper on each server stores its data in the same place?

(I am doing a similar thing now with svn and some custom scripts to commit and revert files, but I have to remember to commit them when I make changes.)

Answer

First, use install etckeeper, configured for git in /etc/etckeeper/etckeeper.conf. Follow etckeeper’s install method for your distro or from source.

Soon, you’ll have a /etc/.git

Now on on your server, make sure you have a (safe) repo to push to…

 # ssh faruser@farhost     
 # mkdir somedir cd somedir && git init && chmod 700 .git    
 # exit

Now on the initial host, push your local repo to the server via ssh:

# cd /etc && git push faruser@farhost:somedir

Somedir can of course be relative in this case (following ssh convention)

Do this any time you make a change that affects /etc (and is snarfed into /etc/.git by etckeeper) and you’ll have both local and off-machine repos for your machine.

Or set up passwordless ssh and make a hook in /etc/etckeeper/commit.d/ so it happens automagically if the machine is always connected.

Attribution
Source : Link , Question Author : Brent , Answer Author : quanta

Leave a Comment