mirror of
https://github.com/famedly/ansible-collection-base
synced 2024-11-10 06:24:17 +00:00
chore(restic): allow adding commandline parameters to restic backup
command
This commit is contained in:
parent
a2f368452c
commit
b6a87fc9c9
3 changed files with 24 additions and 1 deletions
|
@ -24,6 +24,14 @@ To control what and how data is backed up, see:
|
|||
- `restic_backup_commands`: takes an array of dictionaries of
|
||||
the form `{command, filename}`, where the output of `command`
|
||||
is fed into `restic backup --stdin --stdin-filename {{ filename }}`.
|
||||
- `restic_backup_parameters`: takes a dictionary of key-value pairs
|
||||
which are added as commandline parameters to the `restic backup` call
|
||||
for `restic_backup_paths`, for example:
|
||||
```yaml
|
||||
restic_backup_parameters:
|
||||
exclude: /home/user/.cache/
|
||||
verbose:
|
||||
```
|
||||
|
||||
To control when backups are run, see `restic_systemd_timer_on_calendar`
|
||||
and `restic_systemd_timer_accuray_sec`.
|
||||
|
|
|
@ -9,6 +9,7 @@ restic_password: ~
|
|||
|
||||
restic_backup_paths: []
|
||||
restic_backup_commands: []
|
||||
restic_backup_parameters: {}
|
||||
|
||||
restic_systemd_user: root
|
||||
restic_systemd_unit_name: "restic"
|
||||
|
|
|
@ -17,7 +17,21 @@ ExecStart=/bin/sh -c '{{ commands.command }} | {{ restic_binary }} backup --verb
|
|||
{% endfor %}
|
||||
|
||||
{% if restic_backup_paths | length > 0 %}
|
||||
ExecStart={{ restic_binary }} --verbose backup {{ restic_backup_paths | join(' ') }}
|
||||
ExecStart={{ restic_binary }} backup {{ restic_backup_paths | join(' ') }}{% if restic_backup_parameters | length > 0 %} \
|
||||
{% for param in restic_backup_parameters | dict2items %}
|
||||
{%- set outer_loop = loop %}
|
||||
{%- if param.value is not string and param.value is not mapping and param.value is iterable -%}
|
||||
{%- for item in param.value -%}
|
||||
--{{ param.key }}={{ item }}{% if not loop.last %} \
|
||||
{% endif -%}
|
||||
{%- endfor -%}
|
||||
{%- else -%}
|
||||
--{{ param.key }}{% if param.value %}={{ param.value }}{% endif %}
|
||||
{%- endif %}
|
||||
{%- if not outer_loop.last %} \{% endif %}
|
||||
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
ExecStartPost=-{{ restic_binary }} snapshots
|
||||
|
|
Loading…
Reference in a new issue