mirror of
https://github.com/roles-ansible/ansible_role_restic_archiver.git
synced 2024-08-16 10:09:49 +02:00
start improving
This commit is contained in:
parent
0163419f00
commit
ef8e24d58a
3 changed files with 16 additions and 79 deletions
|
@ -1,9 +1,19 @@
|
|||
---
|
||||
# which repos should we cleanup by default
|
||||
restic_archiver__repos: {}
|
||||
# example_server:
|
||||
# - name: example_server:
|
||||
# location: /srv/restic/example_server_repo
|
||||
# password: securepassword4eXaMpleSserver
|
||||
# - name: other_server
|
||||
# location: /srv/restic/other_server_repo
|
||||
# password: xtrasecuredifferentpassword4other
|
||||
# keep_last: 5
|
||||
# keep_hourly: 4
|
||||
# keep_daily: 1
|
||||
# keep_weekly: 1
|
||||
# keep_monthly: 1
|
||||
# keep_yearly: 1
|
||||
# keep_within: 1
|
||||
|
||||
# how long should we store all backups by default
|
||||
restic_archiver__keep: 9
|
||||
|
@ -22,8 +32,8 @@ restic_repos: {}
|
|||
restic_archiver__backups: []
|
||||
restic_create_cron: false
|
||||
|
||||
restic_dir_owner: '{{ ansible_user | default(ansible_user_id) }}'
|
||||
restic_dir_group: '{{ ansible_user | default(ansible_user_id) }}'
|
||||
restic_archiver__dir_owner: '{{ ansible_user | default(ansible_user_id) }}'
|
||||
restic_archiver__dir_group: '{{ ansible_user | default(ansible_user_id) }}'
|
||||
|
||||
# version check for this playbook
|
||||
submodules_versioncheck: false
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
template:
|
||||
src: templates/restic_forget_snapshots.j2
|
||||
dest: /tmp/test
|
||||
group: "{{ restic_archiver__dir_owner }}"
|
||||
owner: "{{ restic_archiver__dir_group }}"
|
||||
|
||||
|
||||
#- include_tasks: template.yml
|
||||
|
||||
|
|
|
@ -57,79 +57,3 @@ BACKUP_NAME="{{ repo.name }}"
|
|||
|
||||
|
||||
{% endfor %}
|
||||
{#
|
||||
export RESTIC_REPOSITORY="{{ restic_repos[item.repo].location }}"
|
||||
export RESTIC_PASSWORD="{{ restic_repos[item.repo].password | regex_replace('\'', '\'\\\'\'') }}"
|
||||
BACKUP_NAME="{{ item.name }}"
|
||||
|
||||
{% if item.src is defined -%}
|
||||
# BACKUP_SOURCE={{ item.src }}
|
||||
{%- endif %}
|
||||
|
||||
|
||||
|
||||
{xxx
|
||||
Define Hostname
|
||||
xxx}
|
||||
{% macro hostname(h) -%}
|
||||
{% if h is defined %} --hostname {{ h }}{% endif %}
|
||||
{%- endmacro %}
|
||||
{xxx
|
||||
Define stdin filename
|
||||
xxx}
|
||||
{% macro stdin_filename(n) -%}
|
||||
{% if n is defined %} --stdin-filename {{ n }}{% endif %}
|
||||
{%- endmacro %}
|
||||
{xxx
|
||||
Define path
|
||||
xxx}
|
||||
{% macro path(repo) -%}
|
||||
{% if repo.src is defined and repo.src != None and (repo.src|length>0) %}{{ repo.src }}{% else %}{{ repo.stdin_filename }}{% endif %}
|
||||
{%- endmacro %}
|
||||
{xxx
|
||||
Define retention pattern
|
||||
xxx}
|
||||
{% macro retention_pattern(repo) -%}
|
||||
{% if repo.keep_last is defined and repo.keep_last != None %}--keep-last {{ item.keep_last }}{% endif %} \
|
||||
{% if repo.keep_hourly is defined and repo.keep_hourly != None %}--keep-hourly {{ item.keep_hourly }}{% endif %} \
|
||||
{% if repo.keep_daily is defined and repo.keep_daily != None %}--keep-daily {{ item.keep_daily }}{% endif %} \
|
||||
{% if repo.keep_weekly is defined and repo.keep_weekly != None %}--keep-weekly {{ item.keep_weekly }}{% endif %} \
|
||||
{% if repo.keep_monthly is defined and repo.keep_monthly != None %}--keep-monthly {{ item.keep_monthly }}{% endif %} \
|
||||
{% if repo.keep_yearly is defined and repo.keep_yearly != None %}--keep-yearly {{ item.keep_yearly }}{% endif %} \
|
||||
{% 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 %}
|
||||
|
||||
|
||||
|
||||
{xxx
|
||||
Define backup commands
|
||||
xxx}
|
||||
{{ restic_install_path }}/restic forget {{ retention_pattern(item) }} {% if item.prune is defined and item.prune == true %}--prune{% endif %}
|
||||
#}
|
||||
|
|
Loading…
Reference in a new issue