Wednesday, March 23, 2016

etckeeper Debian Jessie howto

etckeeper is another great tool for keep a recorder of /etc configuration files changes on your Linux box.

First install etckeeper, it is simple on Debian Jessie:
# apt-get install etckeeper

Generate the key for git server:
root@milliondollarserver:~# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20 root@milliondollarserver
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                 |
|                 |
|        o        |
|       oSo E     |
|        +.... .. |
|       .....o .+=|
|         ..o +.**|
|           .o.=.B|

Setup Git:
root@milliondollarserver:~# git config --global
root@milliondollarserver:~# git config --global root@milliondollarserver
root@milliondollarserver:~# cd /etc/
root@milliondollarserver:/etc# etckeeper init
root@milliondollarserver:/etc# git commit -m "initial checkin"
[master 7c33032] initial checkin
 4 files changed, 14 insertions(+), 4 deletions(-)
 delete mode 100644 check_mk/mysql.cfg
 create mode 100644 python/debian_config
 create mode 100644 python2.7/

Hook it up with my Git server:
cd /etc
git remote rm origin
git remote add origin

Add auto push:
cd /etc/etckeeper/commit.d
(echo ‘#!/bin/sh’ ; echo ‘git push origin’) > 60git-push
chmod +x 60git-push

Try to push:
cd /etc
git add .
git commit -m “automatically push commits to backup repository”
/etc# git push

You will got warning:
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

Run these 2 command to push:
:/etc# git config --global push.default simple
:/etc# git push --set-upstream origin master

You should have output like this:
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ',' (ECDSA) to the list of known hosts.
Counting objects: 1080, done.
Compressing objects: 100% (717/717), done.
Writing objects: 100% (1080/1080), 498.42 KiB | 0 bytes/s, done.
Total 1080 (delta 109), reused 0 (delta 0)
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

No comments:

Post a Comment