diff --git a/README.md b/README.md index 9918297..c5d6348 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/tasks/main.yml b/tasks/main.yml index bca4212..abf711e 100755 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 diff --git a/templates/config.yaml.j2 b/templates/config.yaml.j2 index 9b30c41..1911acb 100644 --- a/templates/config.yaml.j2 +++ b/templates/config.yaml.j2 @@ -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.