mirror of
https://github.com/roles-ansible/ansible_role_restic/
synced 2024-11-09 21:33:31 +01:00
Merge pull request #14 from arillso/12-exclude-options
Add the possibility to exclude certain files
This commit is contained in:
commit
266b0c16ca
3 changed files with 57 additions and 3 deletions
|
@ -4,7 +4,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
and [human-readable changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
## Unreleased
|
||||
### Added:
|
||||
### Added
|
||||
* Config option to exclude files
|
||||
* Contributing guide
|
||||
|
||||
## [0.2.6] 2020-06-05
|
||||
|
|
19
README.md
19
README.md
|
@ -136,6 +136,25 @@ Available variables:
|
|||
| `schedule_hour` | no (`*`) | Hour when the job is run. ( 0-23, *, */2, etc ) |
|
||||
| `schedule_weekday` | no (`*`) | Weekday when the job is run. ( 0-6 for Sunday-Saturday, *, etc ) |
|
||||
| `schedule_month` | no (`*`) | Month when the job is run. ( 1-12, *, */2, etc ) |
|
||||
| `exclude` | no (`{}`) | Allows you to specify files to exclude. See [Exclude](#exclude) for reference. |
|
||||
|
||||
#### Exclude
|
||||
the `exclude` key on a backup allows you to specify multiple files to exclude or
|
||||
files to look for filenames to be excluded. You can specify the following keys:
|
||||
```yaml
|
||||
exclude:
|
||||
exclude_cache: true
|
||||
exclude:
|
||||
- /path/to/file
|
||||
iexclude:
|
||||
- /path/to/file
|
||||
exclude_file:
|
||||
- /path/to/file
|
||||
exclude_if_present:
|
||||
- /path/to/file
|
||||
```
|
||||
Please refer to the use of the specific keys to the
|
||||
[documentation](https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files).
|
||||
|
||||
## Dependencies
|
||||
none
|
||||
|
|
|
@ -62,6 +62,32 @@ set -euxo pipefail
|
|||
{% if repo.keep_within is defined and repo.keep_within != None %}--keep-within {{ item.keep_within }}{% endif %} \
|
||||
{% if repo.keep_tag is defined and (repo.keep_tag|length>0) %}{{ keep_tags(repo.keep_tag) }}{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro exclude(exclude) %}
|
||||
{% if exclude.exclude_cache is defined and exclude.exclude_cache == true %}
|
||||
--exclude-cache \
|
||||
{% endif %}
|
||||
{% if exclude.exclude is defined %}
|
||||
{% for path in exclude.exclude %}
|
||||
--exclude {{ path }} \
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if exclude.iexclude is defined %}
|
||||
{% for path in exclude.iexclude %}
|
||||
--iexclude {{ path }} \
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if exclude.exclude_file is defined %}
|
||||
{% for path in exclude.exclude_file %}
|
||||
--exclude-file {{ path }} \
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if exclude.exclude_if_present is defined %}
|
||||
{% for path in exclude.exclude_if_present %}
|
||||
--exclude-if-present {{ path }} \
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
{#
|
||||
Define backup commands
|
||||
#}
|
||||
|
@ -71,9 +97,17 @@ else
|
|||
MODE_TAG="--tag cron"
|
||||
fi
|
||||
{% if item.stdin is defined and item.stdin == true %}
|
||||
{{ item.stdin_cmd }} | {{ restic_install_path }}/restic backup --stdin $MODE_TAG {{ tags(item.tags) }} {{ stdin_filename(item.stdin_filename) }} $@
|
||||
{{ item.stdin_cmd }} | {{ restic_install_path }}/restic backup \
|
||||
--stdin $MODE_TAG \
|
||||
{{ tags(item.tags) }} \
|
||||
{{ stdin_filename(item.stdin_filename) }} \
|
||||
{% if item.exclude is defined %}{{ exclude(item.exclude) }}{% endif %} \
|
||||
$@
|
||||
{% else %}
|
||||
{{ restic_install_path }}/restic backup $BACKUP_SOURCE $MODE_TAG {{ tags(item.tags) }} $@
|
||||
{{ restic_install_path }}/restic backup $BACKUP_SOURCE $MODE_TAG \
|
||||
{{ tags(item.tags) }} \
|
||||
{% if item.exclude is defined %}{{ exclude(item.exclude) }}{% endif %} \
|
||||
$@
|
||||
{% endif %}
|
||||
{#
|
||||
Define stdin forget commands
|
||||
|
|
Loading…
Reference in a new issue