[backuppc] Factorisation, en vue d'avoir une conf modulaire.
This commit is contained in:
parent
0ad3877053
commit
ee3a587b66
5 changed files with 144 additions and 59 deletions
|
@ -1,5 +1,6 @@
|
||||||
<Bundle name="backuppc">
|
<Bundle name="backuppc">
|
||||||
<Python name="/etc/backuppc/config.pl"/>
|
<Python name="/etc/backuppc/config.pl"/>
|
||||||
<Python name="/etc/backuppc/hosts"/>
|
<Python name="/etc/backuppc/hosts"/>
|
||||||
|
<Path name="/etc/backuppc/config/backups.py"/>
|
||||||
<Package name="backuppc"/>
|
<Package name="backuppc"/>
|
||||||
</Bundle>
|
</Bundle>
|
||||||
|
|
1
Cfg/etc/backuppc/config/backups.py/backups.py
Symbolic link
1
Cfg/etc/backuppc/config/backups.py/backups.py
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../../../../etc/python/backups.py
|
|
@ -1,3 +1,6 @@
|
||||||
|
# -*- coding: utf-8; mode: python -*-
|
||||||
|
|
||||||
|
include("backups")
|
||||||
|
|
||||||
info["owner"] = "backuppc"
|
info["owner"] = "backuppc"
|
||||||
info["group"] = "adm"
|
info["group"] = "adm"
|
||||||
|
@ -67,13 +70,5 @@ def backuppc_hosts(comment, hostslist):
|
||||||
@#larson 1 bill # <--- example DHCP host entry
|
@#larson 1 bill # <--- example DHCP host entry
|
||||||
@
|
@
|
||||||
|
|
||||||
backuppc_hosts("Backups des homes", ["adherentsak", "adherentslz"])
|
backuppc_hosts("Backups des homes", HomeHosts)
|
||||||
# TODO: ci-dessous gérer cette liste via un groupe bcfg2
|
backuppc_hosts("Backups des serveurs", RsyncHosts)
|
||||||
backuppc_hosts("Backups des serveurs",
|
|
||||||
["asterisk", "babar", "cas", "charybde", "dhcp", "irc",
|
|
||||||
"kdell", "komaz", "nat64", "news", "niomniom",
|
|
||||||
"o2",
|
|
||||||
"owl", "radius", "redisdead", "routeur",
|
|
||||||
"sable", "thot", "titanic", "tracker", "vert", "vo",
|
|
||||||
"xmpp",
|
|
||||||
"zamok", "zbee"])
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
include("secrets")
|
include("secrets")
|
||||||
include("ip")
|
include("ip")
|
||||||
|
include("backups")
|
||||||
|
|
||||||
info["perms"] = 0644
|
info["perms"] = 0644
|
||||||
header("Fichier de configuration de rsync")
|
header("Fichier de configuration de rsync")
|
||||||
|
@ -28,57 +29,16 @@ header("Fichier de configuration de rsync")
|
||||||
@# verifie les droits de /etc/rsyncd.secrets
|
@# verifie les droits de /etc/rsyncd.secrets
|
||||||
@strict modes = yes
|
@strict modes = yes
|
||||||
@# personne n'accede aux modules par defaut
|
@# personne n'accede aux modules par defaut
|
||||||
@hosts deny = *
|
@hosts deny = *
|
||||||
@
|
@
|
||||||
@# MODULE OPTIONS
|
@# MODULE OPTIONS
|
||||||
|
|
||||||
# Liste des dossiers a sauvegarder par serveur, en plus de la racine.
|
# Liste des dossiers a sauvegarder par serveur, en plus de la racine.
|
||||||
backup_folders = {
|
|
||||||
'canard' : { 'usr' : '/usr',
|
|
||||||
'var' : '/var' },
|
|
||||||
|
|
||||||
'egon' : { 'usr' : '/usr',
|
backup_folders = RsyncHostsToBackup[hostname]
|
||||||
'var' : '/var' },
|
backup_folders.update(RsyncClassicalDirs)
|
||||||
|
for excluded in RsyncHostsToExclude[hostname]:
|
||||||
'komaz' : { 'var' : '/var' },
|
backup_folders.pop(excluded)
|
||||||
|
|
||||||
'vo' : { 'var' : '/var' },
|
|
||||||
|
|
||||||
'news' : { 'news-spool' : '/var/spool/news',
|
|
||||||
'news-lib' : '/var/lib/news' },
|
|
||||||
|
|
||||||
'sable' : { 'usr' : '/usr',
|
|
||||||
'var' : '/var',
|
|
||||||
'log-squid' : '/var/log/squid3' },
|
|
||||||
|
|
||||||
'charybde' : { 'slash' : '/',
|
|
||||||
'usr' : '/usr',
|
|
||||||
'var' : '/var',
|
|
||||||
'installparty' : '/pubftp/pub/Install-party',
|
|
||||||
'git' : '/pubftp/git' },
|
|
||||||
|
|
||||||
'vert' : { 'var' : '/var',
|
|
||||||
'root' : '/root',
|
|
||||||
},
|
|
||||||
|
|
||||||
'zamok' : { 'var' : '/var',
|
|
||||||
'usr' : '/usr' },
|
|
||||||
|
|
||||||
'niomniom' : { 'www' : '/var/local' },
|
|
||||||
|
|
||||||
'owl': { 'dovecot': '/var/dovecot-indexes' },
|
|
||||||
|
|
||||||
'redisdead' : { 'var': '/var',
|
|
||||||
'mailman': '/var/lib/mailman' },
|
|
||||||
|
|
||||||
'pgsql' : { 'postgresql': '/var/lib/postgresql' },
|
|
||||||
|
|
||||||
'zbee' : { 'adherentsak': '/home-adh',
|
|
||||||
'adherentslz': '/home-adh'},
|
|
||||||
}.get(hostname, {})
|
|
||||||
|
|
||||||
# On rajoute la racine pour tout le monde
|
|
||||||
backup_folders["slash"] = "/"
|
|
||||||
|
|
||||||
ip = admipof("babar")
|
ip = admipof("babar")
|
||||||
|
|
||||||
|
@ -91,6 +51,3 @@ secrets file = /etc/crans/secrets/rsyncd.secrets
|
||||||
hosts allow = babar.adm.crans.org %(ip)s""" % { 'name' : name,
|
hosts allow = babar.adm.crans.org %(ip)s""" % { 'name' : name,
|
||||||
'path' : path,
|
'path' : path,
|
||||||
'ip' : ip }
|
'ip' : ip }
|
||||||
if (hostname, name) == ("vert", "root"):
|
|
||||||
# Sauvegarde des mots de passe chiffres
|
|
||||||
print "include = +*.asc -*"
|
|
||||||
|
|
131
etc/python/backups.py
Normal file
131
etc/python/backups.py
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
#/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Fichier python de gestion des backups
|
||||||
|
#
|
||||||
|
# Auteur : Pierre-Elliott Bécue <becue@crans.org>
|
||||||
|
# Licence : GPLv3
|
||||||
|
# Ne faites jamais include("backups") dans ce fichier !
|
||||||
|
# Le cas échéant, vous allez faire un include cyclique (l'un des deux
|
||||||
|
# est un lien symbolique de l'autre).
|
||||||
|
|
||||||
|
import collections
|
||||||
|
|
||||||
|
# Liste des hosts, pourrait éventuellement être calculée au runtime
|
||||||
|
# via les MetaData
|
||||||
|
RsyncHosts = [
|
||||||
|
"asterisk",
|
||||||
|
"babar",
|
||||||
|
"baldrick",
|
||||||
|
"bcfg2",
|
||||||
|
"cas",
|
||||||
|
"charybde",
|
||||||
|
"dhcp",
|
||||||
|
"eap",
|
||||||
|
"ethercalc",
|
||||||
|
'ft',
|
||||||
|
'fz',
|
||||||
|
"geet",
|
||||||
|
"horde",
|
||||||
|
"irc",
|
||||||
|
"isc",
|
||||||
|
"kdell",
|
||||||
|
"kenobi",
|
||||||
|
"komaz",
|
||||||
|
"nat64",
|
||||||
|
"nem",
|
||||||
|
"news",
|
||||||
|
"niomniom",
|
||||||
|
"o2",
|
||||||
|
"owl",
|
||||||
|
"pea",
|
||||||
|
"radius",
|
||||||
|
"redisdead",
|
||||||
|
"rezosup",
|
||||||
|
"roundcube",
|
||||||
|
"routeur",
|
||||||
|
"sable",
|
||||||
|
"sogo",
|
||||||
|
"thot",
|
||||||
|
"titanic",
|
||||||
|
"tracker",
|
||||||
|
"vert",
|
||||||
|
# "vo", trop de bordel, rien de critique
|
||||||
|
"xmpp",
|
||||||
|
"ytrap-llatsni",
|
||||||
|
"zamok",
|
||||||
|
"zbee",
|
||||||
|
]
|
||||||
|
|
||||||
|
# RsyncHostsToBackup : dictionnaire d'hôtes de la forme
|
||||||
|
# { "hote" : {
|
||||||
|
# 'nomdepartochecool' : 'emplacement de partoche cool',
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# Configs courantes pour les partitions à copier
|
||||||
|
RsyncClassicalDirs = {
|
||||||
|
'slash' : '/',
|
||||||
|
'var' : '/var',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configs spécifiques des partitions à copier pour chaque hôte
|
||||||
|
# copié par rsync
|
||||||
|
RsyncHostsToBackup = collections.defaultdict(dict)
|
||||||
|
|
||||||
|
RsyncHostsToBackup['ft'] = {
|
||||||
|
'pve' : '/etc/pve',
|
||||||
|
}
|
||||||
|
|
||||||
|
RsyncHostsToBackup['fz'] = {
|
||||||
|
'pve' : '/etc/pve',
|
||||||
|
}
|
||||||
|
|
||||||
|
RsyncHostsToBackup['geet'] = {
|
||||||
|
'git' : '/git',
|
||||||
|
'gitlab' : '/gitlab',
|
||||||
|
}
|
||||||
|
|
||||||
|
RsyncHostsToBackup['kdell'] = {
|
||||||
|
'pve' : '/etc/pve',
|
||||||
|
}
|
||||||
|
|
||||||
|
RsyncHostsToBackup['news'] = {
|
||||||
|
'news-spool' : '/var/spool/news',
|
||||||
|
}
|
||||||
|
|
||||||
|
RsyncHostsToBackup['niomniom'] = {
|
||||||
|
'www' : '/var/local',
|
||||||
|
}
|
||||||
|
|
||||||
|
RsyncHostsToBackup['redisdead'] = {
|
||||||
|
'mailman' : '/var/lib/mailman',
|
||||||
|
}
|
||||||
|
|
||||||
|
RsyncHostsToBackup['thot'] = {
|
||||||
|
'boot' : '/boot',
|
||||||
|
}
|
||||||
|
|
||||||
|
RsyncHostsToBackup['zamok'] = {
|
||||||
|
'boot' : '/boot',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Certaines machines n'ont pas de /var à part.
|
||||||
|
# On vire avec ce dico
|
||||||
|
RsyncHostsToExclude = collections.defaultdict(list)
|
||||||
|
|
||||||
|
RsyncHostsToExclude["asterisk"] = [
|
||||||
|
"var",
|
||||||
|
]
|
||||||
|
RsyncHostsToExclude["dhcp"] = [
|
||||||
|
"var",
|
||||||
|
]
|
||||||
|
RsyncHostsToExclude["ytrap-llatsni"] = [
|
||||||
|
"var",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Génération des 26 partitions de backup pour les homes.
|
||||||
|
HomeHosts = ["home-" + lettre for lettre in map(chr, range(97, 123))]
|
||||||
|
|
||||||
|
# Oui, c'est gore, vu que /home n'est qu'une seule partition physique,
|
||||||
|
# il faut enlever à la main chaque lettre de l'alphabet. :'(
|
||||||
|
HomeExclude = { "home-" + lettre : [ "/" + caractere + "*" for caractere in map(chr, range(97, 123)) if caractere != lettre] for lettre in map(chr, range(97, 123))}
|
Loading…
Add table
Add a link
Reference in a new issue