diff --git a/docs/configuring-playbook-backup-borg.md b/docs/configuring-playbook-backup-borg.md index 9507cd6d1..7f87dcd8b 100644 --- a/docs/configuring-playbook-backup-borg.md +++ b/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: diff --git a/roles/matrix-backup-borg/defaults/main.yml b/roles/matrix-backup-borg/defaults/main.yml index fb29b70e2..a7c2bdb75 100644 --- a/roles/matrix-backup-borg/defaults/main.yml +++ b/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 diff --git a/roles/matrix-backup-borg/tasks/validate_config.yml b/roles/matrix-backup-borg/tasks/validate_config.yml index 1f3e39239..4d3fb1c8a 100644 --- a/roles/matrix-backup-borg/tasks/validate_config.yml +++ b/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" diff --git a/roles/matrix-backup-borg/templates/config.yaml.j2 b/roles/matrix-backup-borg/templates/config.yaml.j2 index d96a8a48c..89b6ab7d4 100644 --- a/roles/matrix-backup-borg/templates/config.yaml.j2 +++ b/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 }} diff --git a/roles/matrix-backup-borg/templates/systemd/matrix-backup-borg.service.j2 b/roles/matrix-backup-borg/templates/systemd/matrix-backup-borg.service.j2 index 3325ad1b2..977673ee3 100644 --- a/roles/matrix-backup-borg/templates/systemd/matrix-backup-borg.service.j2 +++ b/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 %}