diff --git a/Bundler/backuppc.xml b/Bundler/backuppc.xml
index dd714a8..1fbb951 100644
--- a/Bundler/backuppc.xml
+++ b/Bundler/backuppc.xml
@@ -1,5 +1,6 @@
+
diff --git a/Cfg/etc/backuppc/config/backups.py/backups.py b/Cfg/etc/backuppc/config/backups.py/backups.py
new file mode 120000
index 0000000..e487c01
--- /dev/null
+++ b/Cfg/etc/backuppc/config/backups.py/backups.py
@@ -0,0 +1 @@
+../../../../../etc/python/backups.py
\ No newline at end of file
diff --git a/Python/etc/backuppc/hosts b/Python/etc/backuppc/hosts
index 1e3c62d..04e327d 100644
--- a/Python/etc/backuppc/hosts
+++ b/Python/etc/backuppc/hosts
@@ -1,3 +1,6 @@
+# -*- coding: utf-8; mode: python -*-
+
+include("backups")
info["owner"] = "backuppc"
info["group"] = "adm"
@@ -67,13 +70,5 @@ def backuppc_hosts(comment, hostslist):
@#larson 1 bill # <--- example DHCP host entry
@
-backuppc_hosts("Backups des homes", ["adherentsak", "adherentslz"])
-# TODO: ci-dessous gérer cette liste via un groupe bcfg2
-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"])
+backuppc_hosts("Backups des homes", HomeHosts)
+backuppc_hosts("Backups des serveurs", RsyncHosts)
diff --git a/Python/etc/rsyncd.conf b/Python/etc/rsyncd.conf
index f5c1259..e2965dc 100644
--- a/Python/etc/rsyncd.conf
+++ b/Python/etc/rsyncd.conf
@@ -2,6 +2,7 @@
include("secrets")
include("ip")
+include("backups")
info["perms"] = 0644
header("Fichier de configuration de rsync")
@@ -28,57 +29,16 @@ header("Fichier de configuration de rsync")
@# verifie les droits de /etc/rsyncd.secrets
@strict modes = yes
@# personne n'accede aux modules par defaut
-@hosts deny = *
+@hosts deny = *
@
@# MODULE OPTIONS
# Liste des dossiers a sauvegarder par serveur, en plus de la racine.
-backup_folders = {
- 'canard' : { 'usr' : '/usr',
- 'var' : '/var' },
- 'egon' : { 'usr' : '/usr',
- 'var' : '/var' },
-
- 'komaz' : { 'var' : '/var' },
-
- '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"] = "/"
+backup_folders = RsyncHostsToBackup[hostname]
+backup_folders.update(RsyncClassicalDirs)
+for excluded in RsyncHostsToExclude[hostname]:
+ backup_folders.pop(excluded)
ip = admipof("babar")
@@ -91,6 +51,3 @@ secrets file = /etc/crans/secrets/rsyncd.secrets
hosts allow = babar.adm.crans.org %(ip)s""" % { 'name' : name,
'path' : path,
'ip' : ip }
- if (hostname, name) == ("vert", "root"):
- # Sauvegarde des mots de passe chiffres
- print "include = +*.asc -*"
diff --git a/etc/python/backups.py b/etc/python/backups.py
new file mode 100644
index 0000000..edcde29
--- /dev/null
+++ b/etc/python/backups.py
@@ -0,0 +1,131 @@
+#/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Fichier python de gestion des backups
+#
+# Auteur : Pierre-Elliott Bécue
+# 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))}