admin:infrastructure:backup
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| admin:infrastructure:backup [2021/01/02 17:49] – [Log rotate] fpoulain | admin:infrastructure:backup [2024/12/29 09:19] (Version actuelle) – [Script de backup] correction d'une typo dans l'URL du remote (suppression ":") pilou | ||
|---|---|---|---|
| Ligne 25: | Ligne 25: | ||
| - '/ | - '/ | ||
| - '/ | - '/ | ||
| - | - '/ | ||
| - '/ | - '/ | ||
| - | - '/ | ||
| repositories: | repositories: | ||
| - | - ' | + | - 'ssh://backup@backup.chapril.org/ |
| storage: | storage: | ||
| Ligne 52: | Ligne 50: | ||
| - for file in / | - for file in / | ||
| - echo " | - echo " | ||
| + | - borgmatic info --archive latest --json | ||
| on_error: | on_error: | ||
| - echo " | - echo " | ||
| Ligne 262: | Ligne 261: | ||
| exit 0 | exit 0 | ||
| + | </ | ||
| + | |||
| + | ==== Rsyslog ==== | ||
| + | |||
| + | <code conf / | ||
| + | if $programname == ' | ||
| + | & stop | ||
| </ | </ | ||
| Ligne 290: | Ligne 296: | ||
| On a un script qui parse sur chaque machine le log de backup et qui est déployé par le paquet monitoring-plugins-chapril : | On a un script qui parse sur chaque machine le log de backup et qui est déployé par le paquet monitoring-plugins-chapril : | ||
| - | <code python / | + | <code python / |
| - | # | + | # |
| - | # -*- encoding: | + | |
| - | import datetime, os, re, locale | + | import datetime, itertools, os, re |
| - | today= datetime.datetime.now () | + | now = datetime.datetime.now(datetime.timezone.utc) |
| - | max_backup_delay = datetime.timedelta (1, 7200) | + | max_backup_delay = datetime.timedelta(1, |
| - | def last_backup | + | def get_name(match): |
| - | | + | return |
| - | logs_ok = re.findall (r'^([ a-zéûA-Z:, | + | |
| - | print "Last backup : " + logs_ok | + | |
| - | try: | + | |
| - | | + | |
| - | except: | + | |
| - | locale.setlocale(locale.LC_ALL, | + | |
| - | return datetime.datetime.strptime | + | |
| + | def check_backup(filename): | ||
| + | with open(filename) as f: | ||
| + | logs = f.read() | ||
| + | mixed_statuses = list(re.finditer(r' | ||
| + | for name, statuses in itertools.groupby(sorted(mixed_statuses, | ||
| + | last = sorted(statuses, | ||
| + | print(' | ||
| + | last_date = datetime.datetime.fromisoformat(last.group(' | ||
| + | last_status = last.group(' | ||
| + | if last_status != ' | ||
| + | failure.append(name) | ||
| + | |||
| + | failure = [] | ||
| try: | try: | ||
| - | | + | |
| - | except: | + | except |
| - | | + | |
| - | if today - last_backup_date < max_backup_delay: | + | if failure: |
| - | exit (0) | + | |
| - | else: | + | |
| exit (1) | exit (1) | ||
| + | else: | ||
| + | exit (0) | ||
| </ | </ | ||
| Ligne 323: | Ligne 334: | ||
| <code conf __admin__/ | <code conf __admin__/ | ||
| object CheckCommand " | object CheckCommand " | ||
| - | command = [ PluginDir + "/check_backup" ] | + | command = [ " |
| } | } | ||
| Ligne 335: | Ligne 346: | ||
| } | } | ||
| </ | </ | ||
| - | |||
| ===== Aspects contrôle d' | ===== Aspects contrôle d' | ||
admin/infrastructure/backup.1609609763.txt.gz · Dernière modification : 2021/01/02 17:49 de fpoulain
