Git server config backup

From campisano.org
Jump to navigation Jump to search

GIT as server config backup

Install

from:

apt-get -y update < /dev/null
apt-get -y install etckeeper git-core metastore < /dev/null
apt-get -y clean < /dev/null
systemctl disable etckeeper.timer
cd /etc
etckeeper uninit -f
rm -rf .git .gitignore .etckeeper
cat > /etc/etckeeper/etckeeper.conf << 'EOF'
VCS="git"
GIT_COMMIT_OPTIONS=""
AVOID_DAILY_AUTOCOMMITS=1
AVOID_COMMIT_BEFORE_INSTALL=1
HIGHLEVEL_PACKAGE_MANAGER=apt
LOWLEVEL_PACKAGE_MANAGER=dpkg
PUSH_REMOTE=""
EOF
etckeeper init
git add .
git config user.name root
git config user.email root@localhost
etckeeper commit "Etckeeper initial commit."

Restore

WARN! use

git checkout HASH

to restore files, but REMEMBER to use

etckeeper init

just after that to restore metadata like file permissions that are not handled by git itself!

from https://serverfault.com/a/286563 (and docs)

    You can use any git commands you like, but do keep in mind that, if you check out a different branch or an old version, git is operating directly on your system's /etc. If you do decide to check out a branch or tag, make sure you run "etckeeper init" again, to get any metadata changes:

    git checkout april_first_joke_etc

    etckeeper init