Aine 3 лет назад
Родитель
Сommit
603b278787
Не найден GPG ключ соответствующий данной подписи Идентификатор GPG ключа: 34969C908CCA2804
5 измененных файлов: 26 добавлений и 23 удалений
  1. +6
    -3
      docs/configuring-playbook-backup-borg.md
  2. +9
    -9
      roles/matrix-backup-borg/defaults/main.yml
  3. +2
    -2
      roles/matrix-backup-borg/tasks/validate_config.yml
  4. +7
    -7
      roles/matrix-backup-borg/templates/config.yaml.j2
  5. +2
    -2
      roles/matrix-backup-borg/templates/systemd/matrix-backup-borg.service.j2

+ 6
- 3
docs/configuring-playbook-backup-borg.md Просмотреть файл

@@ -1,6 +1,9 @@
# Setting up borg backup (optional)

The playbook can install and configure [borgbackup](https://www.borgbackup.org/) with [borgmatic](https://torsion.org/borgmatic/) for you.
BorgBackup is a deduplicating backup program with optional compression and encryption.
That means your daily incremental backups can be stored in a fraction of the space and is safe weather you store it at home or a cloud service.

The backup will run based on `matrix_backup_borg_schedule` var (systemd timer calendar), default: 4am every day

## Prerequisites
@@ -27,11 +30,11 @@ Minimal working configuration (`inventory/host_vars/matrix.DOMAIN/vars.yml`) to

```yaml
matrix_backup_borg_enabled: true
matrix_backup_borg_repositories:
matrix_backup_borg_location_repositories:
- USER@HOST:REPO
matrix_backup_borg_encryption_passphrase: "PASSPHRASE"
matrix_backup_borg_storage_encryption_passphrase: "PASSPHRASE"
matrix_backup_borg_ssh_key_private: |
PRIVATE KEY
PRIVATE KEY
```

where:


+ 9
- 9
roles/matrix-backup-borg/defaults/main.yml Просмотреть файл

@@ -26,11 +26,14 @@ matrix_backup_borg_systemd_wanted_services_list: []
matrix_backup_borg_schedule: "*-*-* 04:00:00"

# what directories should be added to backup
matrix_backup_borg_source_directories:
matrix_backup_borg_location_source_directories:
- "{{ matrix_base_data_path }}"

# target repositories
matrix_backup_borg_location_repositories: []

# exclude following paths:
matrix_backup_borg_exclude_patterns:
matrix_backup_borg_location_exclude_patterns:
- "{{ matrix_synapse_media_store_path }}/local_thumbnails"
- "{{ matrix_synapse_media_store_path }}/remote_thumbnail"
- "{{ matrix_synapse_media_store_path }}/url_cache"
@@ -43,19 +46,16 @@ matrix_backup_borg_encryption: repokey-blake2
matrix_backup_borg_ssh_key_private: ""

# borg ssh command with ssh key
matrix_backup_borg_ssh_command: ssh -o "StrictHostKeyChecking accept-new" -i /etc/borgmatic.d/sshkey

# target repositories
matrix_backup_borg_repositories: []
matrix_backup_borg_storage_ssh_command: ssh -o "StrictHostKeyChecking accept-new" -i /etc/borgmatic.d/sshkey

# compression algorithm
matrix_backup_borg_compression: lz4
matrix_backup_borg_storage_compression: lz4

# archive name format
matrix_backup_borg_archive_name_format: "matrix-{now:%Y-%m-%d-%H%M%S}"
matrix_backup_borg_storage_archive_name_format: "matrix-{now:%Y-%m-%d-%H%M%S}"

# repository passphrase
matrix_backup_borg_encryption_passphrase: ""
matrix_backup_borg_storage_encryption_passphrase: ""

# retention configuration
matrix_backup_borg_retention_keep_hourly: 0


+ 2
- 2
roles/matrix-backup-borg/tasks/validate_config.yml Просмотреть файл

@@ -6,5 +6,5 @@
when: "vars[item] == ''"
with_items:
- "matrix_backup_borg_ssh_key_private"
- "matrix_backup_borg_repositories"
- "matrix_backup_borg_encryption_passphrase"
- "matrix_backup_borg_location_repositories"
- "matrix_backup_borg_storage_encryption_passphrase"

+ 7
- 7
roles/matrix-backup-borg/templates/config.yaml.j2 Просмотреть файл

@@ -1,16 +1,16 @@
#jinja2: lstrip_blocks: "True", trim_blocks: "True"

location:
source_directories: {{ matrix_backup_borg_source_directories|to_json }}
repositories: {{ matrix_backup_borg_repositories|to_json }}
source_directories: {{ matrix_backup_borg_location_source_directories|to_json }}
repositories: {{ matrix_backup_borg_location_repositories|to_json }}
one_file_system: true
exclude_patterns: {{ matrix_backup_borg_exclude_patterns|to_json }}
exclude_patterns: {{ matrix_backup_borg_location_exclude_patterns|to_json }}

storage:
compression: {{ matrix_backup_borg_compression }}
ssh_command: {{ matrix_backup_borg_ssh_command }}
archive_name_format: '{{ matrix_backup_borg_archive_name_format }}'
encryption_passphrase: {{ matrix_backup_borg_encryption_passphrase }}
compression: {{ matrix_backup_borg_storage_compression }}
ssh_command: {{ matrix_backup_borg_storage_ssh_command }}
archive_name_format: '{{ matrix_backup_borg_storage_archive_name_format }}'
encryption_passphrase: {{ matrix_backup_borg_storage_encryption_passphrase }}

retention:
keep_hourly: {{ matrix_backup_borg_retention_keep_hourly }}


+ 2
- 2
roles/matrix-backup-borg/templates/systemd/matrix-backup-borg.service.j2 Просмотреть файл

@@ -24,7 +24,7 @@ ExecStartPre=-{{ matrix_host_command_docker }} run --rm --name matrix-backup-bor
--tmpfs=/tmp:rw,noexec,nosuid,size=100m \
--mount type=bind,src={{ matrix_backup_borg_config_path }}/passwd,dst=/etc/passwd,ro \
--mount type=bind,src={{ matrix_backup_borg_config_path }},dst=/etc/borgmatic.d,ro \
{% for source in matrix_backup_borg_source_directories %}
{% for source in matrix_backup_borg_location_source_directories %}
--mount type=bind,src={{ source }},dst={{ source }},ro \
{% endfor %}
{% for arg in matrix_backup_borg_container_extra_arguments %}
@@ -42,7 +42,7 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-backup-borg \
--tmpfs=/tmp:rw,noexec,nosuid,size=100m \
--mount type=bind,src={{ matrix_backup_borg_config_path }}/passwd,dst=/etc/passwd,ro \
--mount type=bind,src={{ matrix_backup_borg_config_path }},dst=/etc/borgmatic.d,ro \
{% for source in matrix_backup_borg_source_directories %}
{% for source in matrix_backup_borg_location_source_directories %}
--mount type=bind,src={{ source }},dst={{ source }},ro \
{% endfor %}
{% for arg in matrix_backup_borg_container_extra_arguments %}


Загрузка…
Отмена
Сохранить