Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
1 result

Target

Select target project
  • ansible/roles/borgbackup
1 result
Select Git revision
  • main
1 result
Show changes
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
# file: roles/borgbackup/handlers/main.yml # file: roles/borgbackup/handlers/main.yml
- name: Init Borgs - name: Init Borgs
command: borgmatic init --encryption repokey command: echo "borgmatic init --encryption repokey"
...@@ -9,6 +9,15 @@ ...@@ -9,6 +9,15 @@
notify: notify:
- Init Borgs - Init Borgs
- name: Add Borgmatic Check
template:
src: check_config.yaml
dest: /etc/borgmatic/check/config.yaml
mode: 0600
notify:
- Init Borgs
when: not borgbackup.disable_local|default(false)
- name: Add Borgmatic Configuration for Drupal - name: Add Borgmatic Configuration for Drupal
include_tasks: config_drupal.yml include_tasks: config_drupal.yml
with_items: '{{ drupal_settings|default([]) }}' with_items: '{{ drupal_settings|default([]) }}'
...@@ -23,22 +32,34 @@ ...@@ -23,22 +32,34 @@
loop_var: nextcloud loop_var: nextcloud
when: nextcloud.borg_enabled|default("yes") == "yes" when: nextcloud.borg_enabled|default("yes") == "yes"
- name: Add cron job for create, check and prune - name: Add cron job for create and prune
cron: cron:
name: borgmatic name: borgmatic
hour: '{{ borgbackup_cron_hour|default(4) }}' hour: '{{ borgbackup_cron_hour|default(4) }}'
minute: 0 minute: 0
cron_file: borgmatic cron_file: borgmatic
user: root user: root
job: /usr/local/bin/borgmatic -v 1 >> /var/log/borg.log 2>&1 job: /usr/local/bin/borgmatic -v 1 --create --prune >> /var/log/borg.log 2>&1
- name: Set PATH for borgmatic cron job. - name: Add cron job for check
cron: cron:
name: borgmatic-check
day: 1
hour: 23
minute: 30
cron_file: borgmatic cron_file: borgmatic
user: root user: root
job: /usr/local/bin/borgmatic -v 1 --check >> /var/log/borg.log 2>&1
- name: Set PATH for borgmatic cron job.
cron:
cron_file: '{{ item }}'
user: root
name: PATH name: PATH
env: yes env: yes
value: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin value: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
with_items:
- borgmatic
- name: Add repo server host key to known hosts - name: Add repo server host key to known hosts
known_hosts: known_hosts:
......
...@@ -34,6 +34,15 @@ ...@@ -34,6 +34,15 @@
notify: notify:
- Init Borgs - Init Borgs
- name: Configure Drupal Check
template:
src: check_application.yaml
dest: /etc/borgmatic.d/check/{{ application }}_{{ application_id }}.yaml
mode: 0600
notify:
- Init Borgs
when: not application_disable_local|default(false)
- name: Add repo server host key to known hosts - name: Add repo server host key to known hosts
known_hosts: known_hosts:
name: '{{ application_remote_host }}' name: '{{ application_remote_host }}'
......
...@@ -25,6 +25,15 @@ ...@@ -25,6 +25,15 @@
notify: notify:
- Init Borgs - Init Borgs
- name: Configure Nextcloud Check
template:
src: check_application.yaml
dest: /etc/borgmatic.d/check/{{ application }}_{{ application_id }}.yaml
mode: 0600
notify:
- Init Borgs
when: not application_disable_local|default(false)
- name: Add repo server host key to known hosts - name: Add repo server host key to known hosts
known_hosts: known_hosts:
name: '{{ application_remote_host }}' name: '{{ application_remote_host }}'
......
...@@ -44,4 +44,6 @@ ...@@ -44,4 +44,6 @@
with_items: with_items:
- /var/backups/borg - /var/backups/borg
- /etc/borgmatic - /etc/borgmatic
- /etc/borgmatic/check
- /etc/borgmatic.d - /etc/borgmatic.d
- /etc/borgmatic.d/check
...@@ -35,6 +35,7 @@ retention: ...@@ -35,6 +35,7 @@ retention:
consistency: consistency:
checks: checks:
- repository - repository
- archives
hooks: hooks:
before_backup: before_backup:
- echo "`date` - Starting backup" - echo "`date` - Starting backup"
......
location:
source_directories:
{% if application_mountpoints|default(false) %}
{% for mountpoint in application_mountpoints %}
- {{ mountpoint.path }}
{% endfor %}
{% else %}
- {{ 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 }}'
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 Backup Exception","value":"{{ application }} {{ application_id }}"}'
location:
source_directories:
- /etc
{% for dir in backup_include|default([]) %}
- {{ dir }}
{% endfor %}
{% if groups['dbserver_mysql'] is defined and inventory_hostname in groups['dbserver_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 }}'
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 Backup Exception","value":"Default"}'
...@@ -35,6 +35,7 @@ retention: ...@@ -35,6 +35,7 @@ retention:
consistency: consistency:
checks: checks:
- repository - repository
- archives
hooks: hooks:
before_backup: before_backup:
- echo "`date` - Starting backup" - echo "`date` - Starting backup"
......