Support for multiple repositories. By @p-rintz (#41)

This commit is contained in:
Philipp Rintz 2020-11-18 04:41:57 +01:00 committed by GitHub
parent 0a490a3a6f
commit ee6f93f71b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -51,7 +51,7 @@ $ git clone https://github.com/borgbase/ansible-role-borgbackup.git roles/borgba
## Role Variables
### Required Arguments
- `borg_repository`: Full path to repository. Your own server or [BorgBase.com](https://www.borgbase.com) repo. Not required when using auto creation of repositories.
- `borg_repository`: Full path to repository. Your own server or [BorgBase.com](https://www.borgbase.com) repo. Not required when using auto creation of repositories. Can be a list if you want to backup to multiple repositories.
- `borg_source_directories`: List of local folders to back up.
### Optional Arguments
@ -80,7 +80,7 @@ $ git clone https://github.com/borgbase/ansible-role-borgbackup.git roles/borgba
### Optional Arguments for [BorgBase.com](https://www.borgbase.com) repository auto creation
This role can also set up a new repository on BorgBase, using the arguments below. Thanks to [Philipp Rintz](https://github.com/p-rintz) for contribution this feature.
This role can also set up a new repository on BorgBase, using the arguments below. Thanks to [Philipp Rintz](https://github.com/p-rintz) for contribution of this feature.
- `create_repo`: Whether to let the role create the repository for the server. Default: False
- `bb_token`: Your [BorgBase.com](https://www.borgbase.com) API-Token. Should be Create Only for security reasons.

View File

@ -60,7 +60,14 @@
- name: Set Repository Fact
set_fact:
borg_repository: "{{ repo_creation['data']['repoPath'] }}"
borg_repository: |-
{% if borg_repository is defined and borg_repository is string %}
{{ [borg_repository] + [ repo_creation['data']['repoPath'] ] }}
{% elif borg_repository is defined %}
{{ borg_repository + [ repo_creation['data']['repoPath'] ] }}
{% else %}
{{ repo_creation['data']['repoPath'] }}
{% endif %}
when: create_repo
- name: Ensures /etc/borgmatic exists

View File

@ -1,3 +1,4 @@
#jinja2: lstrip_blocks: "True", trim_blocks: "True"
# Full config: https://gist.github.com/coaxial/46e36d89d7b81887f7275d587fe04c44
location:
source_directories:
@ -8,7 +9,13 @@ location:
# Stay in same file system (do not cross mount points).
one_file_system: {{ borg_one_file_system }}
repositories:
{% if borg_repository is iterable and (borg_repository is not string and borg_repository is not mapping) %}
{% for repo in borg_repository %}
- {{ repo }}
{% endfor %}
{% elif borg_repository is defined and borg_repository is string %}
- {{ borg_repository }}
{% endif %}
# Any paths matching these patterns are excluded from backups. Globs and tildes
# are expanded. See the output of "borg help patterns" for more details.