Procházet zdrojové kódy

feedback

pull/1727/head
Aine před 3 roky
rodič
revize
603b278787
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: 34969C908CCA2804
5 změnil soubory, kde provedl 26 přidání a 23 odebrání
  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 Zobrazit soubor

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


The playbook can install and configure [borgbackup](https://www.borgbackup.org/) with [borgmatic](https://torsion.org/borgmatic/) for you. 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 The backup will run based on `matrix_backup_borg_schedule` var (systemd timer calendar), default: 4am every day


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


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


where: where:


+ 9
- 9
roles/matrix-backup-borg/defaults/main.yml Zobrazit soubor

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


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


# target repositories
matrix_backup_borg_location_repositories: []

# exclude following paths: # 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 }}/local_thumbnails"
- "{{ matrix_synapse_media_store_path }}/remote_thumbnail" - "{{ matrix_synapse_media_store_path }}/remote_thumbnail"
- "{{ matrix_synapse_media_store_path }}/url_cache" - "{{ matrix_synapse_media_store_path }}/url_cache"
@@ -43,19 +46,16 @@ matrix_backup_borg_encryption: repokey-blake2
matrix_backup_borg_ssh_key_private: "" matrix_backup_borg_ssh_key_private: ""


# borg ssh command with ssh key # 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 # compression algorithm
matrix_backup_borg_compression: lz4
matrix_backup_borg_storage_compression: lz4


# archive name format # 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 # repository passphrase
matrix_backup_borg_encryption_passphrase: ""
matrix_backup_borg_storage_encryption_passphrase: ""


# retention configuration # retention configuration
matrix_backup_borg_retention_keep_hourly: 0 matrix_backup_borg_retention_keep_hourly: 0


+ 2
- 2
roles/matrix-backup-borg/tasks/validate_config.yml Zobrazit soubor

@@ -6,5 +6,5 @@
when: "vars[item] == ''" when: "vars[item] == ''"
with_items: with_items:
- "matrix_backup_borg_ssh_key_private" - "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 Zobrazit soubor

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


location: 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 one_file_system: true
exclude_patterns: {{ matrix_backup_borg_exclude_patterns|to_json }}
exclude_patterns: {{ matrix_backup_borg_location_exclude_patterns|to_json }}


storage: 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: retention:
keep_hourly: {{ matrix_backup_borg_retention_keep_hourly }} keep_hourly: {{ matrix_backup_borg_retention_keep_hourly }}


+ 2
- 2
roles/matrix-backup-borg/templates/systemd/matrix-backup-borg.service.j2 Zobrazit soubor

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


Načítá se…
Zrušit
Uložit