From 5d65bff6fc3084307ea3d3fbb97c5d776d98d7c9 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen.haas@lakedrops.com>
Date: Sun, 4 Feb 2024 11:24:57 +0100
Subject: [PATCH] ansible/roles/borgbackup#4 Update borgmatic configuration

---
 templates/app.yaml               | 84 ++++++++++++++++----------------
 templates/application.yaml       | 72 +++++++++++++--------------
 templates/check_application.yaml | 71 +++++++++++++--------------
 templates/check_config.yaml      | 73 +++++++++++++--------------
 templates/config.yaml            | 74 ++++++++++++++--------------
 5 files changed, 181 insertions(+), 193 deletions(-)

diff --git a/templates/app.yaml b/templates/app.yaml
index c7d76c4..e1398b3 100644
--- a/templates/app.yaml
+++ b/templates/app.yaml
@@ -1,49 +1,47 @@
-location:
-    source_directories:
-        - /mnt/source
-    repositories:
-        - /mnt/borg-repository
+source_directories:
+    - /mnt/source
+repositories:
+    - path: /mnt/borg-repository
+      label: local
 {% if application_remote_repo %}
-        - {{ application_remote_repo }}
+    - path: {{ application_remote_repo }}
+      label: remote
 {% endif %}
-    one_file_system: true
-    exclude_patterns:
-        - '*.log'
-        - '*.pyc'
-        - '*/.git'
-        - '*/.svn'
-        - '*/vendor/*'
-        - '*/node_modules/*'
-    exclude_caches: true
-    exclude_if_present: '.nobackup'
-storage:
-    encryption_passphrase: '{{ borg_passphrase }}'
-    retries: {{ borgbackup.retries|default(1) }}
-    retry_wait: 300
-retention:
-    keep_daily: 7
-    keep_weekly: 8
-    keep_monthly: 12
-    keep_yearly: 30
-consistency:
-    checks:
-        - repository
-        - archives
-hooks:
+one_file_system: true
+exclude_patterns:
+    - '*.log'
+    - '*.pyc'
+    - '*/.git'
+    - '*/.svn'
+    - '*/vendor/*'
+    - '*/node_modules/*'
+exclude_caches: true
+exclude_if_present:
+    - '.nobackup'
+encryption_passphrase: '{{ borg_passphrase }}'
+retries: {{ borgbackup.retries|default(1) }}
+retry_wait: 300
+keep_daily: 7
+keep_weekly: 8
+keep_monthly: 12
+keep_yearly: 30
+checks:
+    - name: repository
+    - name: archives
 {% if application_db is defined %}
-    mysql_databases:
-        - name: '{{ application_db }}'
-          hostname: db
-          port: 3306
-          username: '{{ application_db }}'
-          password: '{{ application_db }}'
-          options: '--skip-comments --no-tablespaces'
+mysql_databases:
+    - name: '{{ application_db }}'
+      hostname: db
+      port: 3306
+      username: '{{ application_db }}'
+      password: '{{ application_db }}'
+      options: '--skip-comments --no-tablespaces'
 {% endif %}
-    before_backup:
-        - echo "`date` - Starting backup"
-    after_backup:
-        - echo "`date` - Finished backup"
+before_backup:
+    - echo "`date` - Starting backup"
+after_backup:
+    - echo "`date` - Finished backup"
 {% if alerta_apikey is defined %}
-    on_error:
-        - echo -n '{"service":["https://www.borgbase.com"],"resource":"{{ inventory_hostname }}","event":"Borg {configuration_filename}","value":"{{ application }} {{ application_id }} {repository}","text":"Borg {configuration_filename}","rawData":"{output}"}' | nc -u -w1 alerta {{ alerta_proxy_port|default(20002) }}
+on_error:
+    - echo -n '{"service":["https://www.borgbase.com"],"resource":"{{ inventory_hostname }}","event":"Borg {configuration_filename}","value":"{{ application }} {{ application_id }} {repository}","text":"Borg {configuration_filename}","rawData":"{output}"}' | nc -u -w1 alerta {{ alerta_proxy_port|default(20002) }}
 {% endif %}
diff --git a/templates/application.yaml b/templates/application.yaml
index 9db0300..fe311db 100644
--- a/templates/application.yaml
+++ b/templates/application.yaml
@@ -1,46 +1,44 @@
-location:
-    source_directories:
+source_directories:
 {% if application_mountpoints|default(false) %}
 {% for mountpoint in application_mountpoints %}
-        - {{ mountpoint.path }}
+    - {{ mountpoint.path }}
 {% endfor %}
 {% else %}
-        - {{ application_dir }}
+    - {{ application_dir }}
 {% endif %}
-    repositories:
+repositories:
 {% if not application_disable_local %}
-        - /var/backups/borg/{{ application }}_{{ application_id }}
+    - path: /var/backups/borg/{{ application }}_{{ application_id }}
+      label: local
 {% endif %}
 {% if application_remote_repo %}
-        - {{ application_remote_repo }}
+    - path: {{ application_remote_repo }}
+      label: remote
 {% endif %}
-    one_file_system: true
-    exclude_patterns:
-        - '*.log'
-        - '*.pyc'
-        - '*/.git'
-        - '*/.svn'
-        - '*/vendor/*'
-        - '*/node_modules/*'
-    exclude_caches: true
-    exclude_if_present: '.nobackup'
-storage:
-    encryption_passphrase: '{{ borgbackup.passphrase }}'
-    retries: {{ borgbackup.retries|default(1) }}
-    retry_wait: 300
-retention:
-    keep_daily: 7
-    keep_weekly: 8
-    keep_monthly: 12
-    keep_yearly: 30
-consistency:
-    checks:
-        - repository
-        - archives
-hooks:
-    before_backup:
-        - echo "`date` - Starting backup"
-    after_backup:
-        - echo "`date` - Finished backup"
-    on_error:
-        - /usr/local/bin/alertalerta.py{% if netdata_alerta_project_id is defined %} --pid={{ netdata_alerta_project_id }}{% endif %} {{ inventory_hostname }} {{ netdata_alerta_environment|default("production") }} {{ netdata_alerta_webhook }} {{ netdata_alerta_apikey }} '{"service":["https://www.borgbase.com"],"resource":"{{ inventory_hostname }}","event":"Borg {configuration_filename}","value":"{{ application }} {{ application_id }} {repository}","text":"Borg {configuration_filename}","rawData":"{output}"}'
+one_file_system: true
+exclude_patterns:
+    - '*.log'
+    - '*.pyc'
+    - '*/.git'
+    - '*/.svn'
+    - '*/vendor/*'
+    - '*/node_modules/*'
+exclude_caches: true
+exclude_if_present:
+    - '.nobackup'
+encryption_passphrase: '{{ borgbackup.passphrase }}'
+retries: {{ borgbackup.retries|default(1) }}
+retry_wait: 300
+keep_daily: 7
+keep_weekly: 8
+keep_monthly: 12
+keep_yearly: 30
+checks:
+    - name: repository
+    - name: archives
+before_backup:
+    - echo "`date` - Starting backup"
+after_backup:
+    - echo "`date` - Finished backup"
+on_error:
+    - /usr/local/bin/alertalerta.py{% if netdata_alerta_project_id is defined %} --pid={{ netdata_alerta_project_id }}{% endif %} {{ inventory_hostname }} {{ netdata_alerta_environment|default("production") }} {{ netdata_alerta_webhook }} {{ netdata_alerta_apikey }} '{"service":["https://www.borgbase.com"],"resource":"{{ inventory_hostname }}","event":"Borg {configuration_filename}","value":"{{ application }} {{ application_id }} {repository}","text":"Borg {configuration_filename}","rawData":"{output}"}'
diff --git a/templates/check_application.yaml b/templates/check_application.yaml
index aa05b4b..eda54c6 100644
--- a/templates/check_application.yaml
+++ b/templates/check_application.yaml
@@ -1,42 +1,39 @@
-location:
-    source_directories:
+source_directories:
 {% if application_mountpoints|default(false) %}
 {% for mountpoint in application_mountpoints %}
-        - {{ mountpoint.path }}
+    - {{ mountpoint.path }}
 {% endfor %}
 {% else %}
-        - {{ application_dir }}
+    - {{ application_dir }}
 {% endif %}
-    repositories:
-        - /var/backups/borg/{{ application }}_{{ application_id }}
-    one_file_system: true
-    exclude_patterns:
-        - '*.log'
-        - '*.pyc'
-        - '*/.git'
-        - '*/.svn'
-        - '*/vendor/*'
-        - '*/node_modules/*'
-    exclude_caches: true
-    exclude_if_present: '.nobackup'
-storage:
-    encryption_passphrase: '{{ borgbackup.passphrase }}'
-    retries: 1
-    retry_wait: 300
-retention:
-    keep_daily: 7
-    keep_weekly: 8
-    keep_monthly: 12
-    keep_yearly: 30
-consistency:
-    checks:
-        - archives
-        - data
-        - repository
-hooks:
-    before_backup:
-        - echo "`date` - Starting backup"
-    after_backup:
-        - echo "`date` - Finished backup"
-    on_error:
-        - /usr/local/bin/alertalerta.py{% if netdata_alerta_project_id is defined %} --pid={{ netdata_alerta_project_id }}{% endif %} {{ inventory_hostname }} {{ netdata_alerta_environment|default("production") }} {{ netdata_alerta_webhook }} {{ netdata_alerta_apikey }} '{"service":["https://www.borgbase.com"],"resource":"{{ inventory_hostname }}","event":"Borg {configuration_filename}","value":"{{ application }} {{ application_id }} {repository}","text":"Borg {configuration_filename}","rawData":"{output}"}'
+repositories:
+    - path: /var/backups/borg/{{ application }}_{{ application_id }}
+      label: local
+one_file_system: true
+exclude_patterns:
+    - '*.log'
+    - '*.pyc'
+    - '*/.git'
+    - '*/.svn'
+    - '*/vendor/*'
+    - '*/node_modules/*'
+exclude_caches: true
+exclude_if_present:
+    - '.nobackup'
+encryption_passphrase: '{{ borgbackup.passphrase }}'
+retries: 1
+retry_wait: 300
+keep_daily: 7
+keep_weekly: 8
+keep_monthly: 12
+keep_yearly: 30
+checks:
+    - name: archives
+    - name: data
+    - name: repository
+before_backup:
+    - echo "`date` - Starting backup"
+after_backup:
+    - echo "`date` - Finished backup"
+on_error:
+    - /usr/local/bin/alertalerta.py{% if netdata_alerta_project_id is defined %} --pid={{ netdata_alerta_project_id }}{% endif %} {{ inventory_hostname }} {{ netdata_alerta_environment|default("production") }} {{ netdata_alerta_webhook }} {{ netdata_alerta_apikey }} '{"service":["https://www.borgbase.com"],"resource":"{{ inventory_hostname }}","event":"Borg {configuration_filename}","value":"{{ application }} {{ application_id }} {repository}","text":"Borg {configuration_filename}","rawData":"{output}"}'
diff --git a/templates/check_config.yaml b/templates/check_config.yaml
index 9b317d7..8efc6bb 100644
--- a/templates/check_config.yaml
+++ b/templates/check_config.yaml
@@ -1,42 +1,39 @@
-location:
-    source_directories:
-        - /etc
+source_directories:
+    - /etc
 {% for dir in backup_include|default([]) %}
-        - {{ dir }}
+    - {{ dir }}
 {% endfor %}
 {% if groups['dbserver_mysql'] is defined and inventory_hostname in groups['dbserver_mysql'] %}
-        - /var/backups/mysql
+    - /var/backups/mysql
 {% endif %}
-    repositories:
-        - /var/backups/borg/default
-    one_file_system: true
-    exclude_patterns:
-        - '*.log'
-        - '*.pyc'
-        - '*/.git'
-        - '*/.svn'
-        - '*/vendor/*'
-        - '*/node_modules/*'
-    exclude_caches: true
-    exclude_if_present: '.nobackup'
-storage:
-    encryption_passphrase: '{{ borgbackup.passphrase }}'
-    retries: 1
-    retry_wait: 300
-retention:
-    keep_daily: 7
-    keep_weekly: 8
-    keep_monthly: 12
-    keep_yearly: 30
-consistency:
-    checks:
-        - archives
-        - data
-        - repository
-hooks:
-    before_backup:
-        - echo "`date` - Starting backup"
-    after_backup:
-        - echo "`date` - Finished backup"
-    on_error:
-        - /usr/local/bin/alertalerta.py{% if netdata_alerta_project_id is defined %} --pid={{ netdata_alerta_project_id }}{% endif %} {{ inventory_hostname }} {{ netdata_alerta_environment|default("production") }} {{ netdata_alerta_webhook }} {{ netdata_alerta_apikey }} '{"service":["https://www.borgbase.com"],"resource":"{{ inventory_hostname }}","event":"Borg {configuration_filename}","value":"{repository}","text":"Borg {configuration_filename}","rawData":"{output}"}'
+repositories:
+    - path: /var/backups/borg/default
+      label: local
+one_file_system: true
+exclude_patterns:
+    - '*.log'
+    - '*.pyc'
+    - '*/.git'
+    - '*/.svn'
+    - '*/vendor/*'
+    - '*/node_modules/*'
+exclude_caches: true
+exclude_if_present:
+    - '.nobackup'
+encryption_passphrase: '{{ borgbackup.passphrase }}'
+retries: 1
+retry_wait: 300
+keep_daily: 7
+keep_weekly: 8
+keep_monthly: 12
+keep_yearly: 30
+checks:
+    - name: archives
+    - name: data
+    - name: repository
+before_backup:
+    - echo "`date` - Starting backup"
+after_backup:
+    - echo "`date` - Finished backup"
+on_error:
+    - /usr/local/bin/alertalerta.py{% if netdata_alerta_project_id is defined %} --pid={{ netdata_alerta_project_id }}{% endif %} {{ inventory_hostname }} {{ netdata_alerta_environment|default("production") }} {{ netdata_alerta_webhook }} {{ netdata_alerta_apikey }} '{"service":["https://www.borgbase.com"],"resource":"{{ inventory_hostname }}","event":"Borg {configuration_filename}","value":"{repository}","text":"Borg {configuration_filename}","rawData":"{output}"}'
diff --git a/templates/config.yaml b/templates/config.yaml
index ca74423..5e9f88b 100644
--- a/templates/config.yaml
+++ b/templates/config.yaml
@@ -1,46 +1,44 @@
-location:
-    source_directories:
-        - /etc
+source_directories:
+    - /etc
 {% for dir in backup_include|default([]) %}
-        - {{ dir }}
+    - {{ dir }}
 {% endfor %}
 {% if groups['dbserver_mysql'] is defined and inventory_hostname in groups['dbserver_mysql'] %}
-        - /var/backups/mysql
+    - /var/backups/mysql
 {% endif %}
-    repositories:
+repositories:
 {% if not borgbackup.disable_local|default(false) %}
-        - /var/backups/borg/default
+    - path: /var/backups/borg/default
+      label: local
 {% endif %}
 {% if borgbackup.remote_repo is defined %}
-        - {{ borgbackup.remote_repo }}
+    - path: {{ borgbackup.remote_repo }}
+      label: remote
 {% endif %}
-    one_file_system: true
-    exclude_patterns:
-        - '*.log'
-        - '*.pyc'
-        - '*/.git'
-        - '*/.svn'
-        - '*/vendor/*'
-        - '*/node_modules/*'
-    exclude_caches: true
-    exclude_if_present: '.nobackup'
-storage:
-    encryption_passphrase: '{{ borgbackup.passphrase }}'
-    retries: 1
-    retry_wait: 300
-retention:
-    keep_daily: 7
-    keep_weekly: 8
-    keep_monthly: 12
-    keep_yearly: 30
-consistency:
-    checks:
-        - repository
-        - archives
-hooks:
-    before_backup:
-        - echo "`date` - Starting backup"
-    after_backup:
-        - echo "`date` - Finished backup"
-    on_error:
-        - /usr/local/bin/alertalerta.py{% if netdata_alerta_project_id is defined %} --pid={{ netdata_alerta_project_id }}{% endif %} {{ inventory_hostname }} {{ netdata_alerta_environment|default("production") }} {{ netdata_alerta_webhook }} {{ netdata_alerta_apikey }} '{"service":["https://www.borgbase.com"],"resource":"{{ inventory_hostname }}","event":"Borg {configuration_filename}","value":"{repository}","text":"Borg {configuration_filename}","rawData":"{output}"}'
+one_file_system: true
+exclude_patterns:
+    - '*.log'
+    - '*.pyc'
+    - '*/.git'
+    - '*/.svn'
+    - '*/vendor/*'
+    - '*/node_modules/*'
+exclude_caches: true
+exclude_if_present:
+    - '.nobackup'
+encryption_passphrase: '{{ borgbackup.passphrase }}'
+retries: 1
+retry_wait: 300
+keep_daily: 7
+keep_weekly: 8
+keep_monthly: 12
+keep_yearly: 30
+checks:
+    - name: repository
+    - name: archives
+before_backup:
+    - echo "`date` - Starting backup"
+after_backup:
+    - echo "`date` - Finished backup"
+on_error:
+    - /usr/local/bin/alertalerta.py{% if netdata_alerta_project_id is defined %} --pid={{ netdata_alerta_project_id }}{% endif %} {{ inventory_hostname }} {{ netdata_alerta_environment|default("production") }} {{ netdata_alerta_webhook }} {{ netdata_alerta_apikey }} '{"service":["https://www.borgbase.com"],"resource":"{{ inventory_hostname }}","event":"Borg {configuration_filename}","value":"{repository}","text":"Borg {configuration_filename}","rawData":"{output}"}'
-- 
GitLab