Revision 679008e7

b/Makefile.am
58 58
	doc/examples/bash_completion \
59 59
	doc/examples/ganeti.initd \
60 60
	doc/examples/ganeti.cron \
61
	doc/examples/gnt-config-backup \
61 62
	doc/examples/hooks/ipsec \
62 63
	lib/*.py[co] \
63 64
	lib/build/*.py[co] \
......
189 190
	doc/examples/bash_completion \
190 191
	doc/examples/ganeti.cron \
191 192
	doc/examples/ganeti.initd \
193
	doc/examples/gnt-config-backup \
192 194
	doc/examples/hooks/ipsec \
193 195
	$(manhtml)
194 196

  
......
234 236
	doc/html \
235 237
	doc/examples/ganeti.initd.in \
236 238
	doc/examples/ganeti.cron.in \
239
	doc/examples/gnt-config-backup.in \
237 240
	doc/examples/dumb-allocator \
238 241
	doc/examples/hooks/ethers \
239 242
	doc/examples/hooks/ipsec.in \
b/doc/examples/gnt-config-backup.in
1
#!/bin/bash
2

  
3
# Copyright (C) 2009 Google Inc.
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19

  
20

  
21
# This is an example ganeti script that should be run from cron on all
22
# nodes; it will archive the ganeti configuration into a separate
23
# directory tree via GIT, so that it is possible to restore the
24
# history of cluster configuration changes if needed
25

  
26
# The script requires the lockfile-progs package and the git software
27

  
28
# Note that since Ganeti 2.0, config.data is the authoritative source
29
# of configuration; as such, we don't need to backup the ssconf files,
30
# and the other files (server.pem, rapi.pem, hmac.key, known_hosts,
31
# etc.) do no hold critical data (they can be regenerated at will, as
32
# long as they are synchronised).
33

  
34
set -e
35

  
36
LOCALSTATEDIR=@LOCALSTATEDIR@
37
SYSCONFDIR=@SYSCONFDIR@
38

  
39
GANETIDIR=${LOCALSTATEDIR}/lib/ganeti
40
CONFIGDATA=${GANETIDIR}/config.data
41

  
42
GNTBKDIR=${LOCALSTATEDIR}/lib/gnt-config-backup
43
LOCKFILE=${LOCALSTATEDIR}/lock/gnt-config-backup
44

  
45
# exit if no ganeti config file (no cluster configured, or not M/MC)
46
test -f $CONFIGDATA || exit 0
47

  
48
# We use a simple lock method, since our script should be fast enough
49
# (no network, not talking to ganeti-masterd) that we don't expect to
50
# run over 5 minutes if the system is healthy
51
lockfile-create "$LOCKFILE" || exit 1
52
trap 'lockfile-remove $LOCKFILE' EXIT
53

  
54
test -d $GNTBKDIR || mkdir $GNTBKDIR
55

  
56
cd $GNTBKDIR
57

  
58
test -d .git || git init
59

  
60
cp -f $CONFIGDATA config.data
61
git add config.data
62
git commit -q -m "Automatic commit by gnt-config-backup"
63

  
64
touch last_run

Also available in: Unified diff