mirror of
https://github.com/roles-ansible/ansible_role_restic_archiver.git
synced 2024-08-16 10:09:49 +02:00
replace template with better fitting content
This commit is contained in:
parent
154b659318
commit
a075ace31b
3 changed files with 30 additions and 32 deletions
|
@ -13,11 +13,16 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Description
|
Description
|
||||||
|
----------------
|
||||||
[Restic](https://github.com/restic/restic) is a versatile Go based backup
|
[Restic](https://github.com/restic/restic) is a versatile Go based backup
|
||||||
solution which supports multiple backends, deduplication and incremental
|
solution which supports multiple backends, deduplication and incremental
|
||||||
backups.
|
backups.
|
||||||
|
|
||||||
|
This role is **only intended to clean up a restick backup**. So for example to keep only backups of the last 7 days and monthly backups. And if necessary to copy the backups again to an external storage.
|
||||||
|
|
||||||
|
----------------------
|
||||||
|
|
||||||
This role installs restic on a client, configures the backup repositories
|
This role installs restic on a client, configures the backup repositories
|
||||||
and optionally sets up cronjobs to run said backups.
|
and optionally sets up cronjobs to run said backups.
|
||||||
Aditionally, it will setup executable scripts to run a Backup manually.
|
Aditionally, it will setup executable scripts to run a Backup manually.
|
||||||
|
|
|
@ -39,12 +39,13 @@
|
||||||
|
|
||||||
- name: Setup CRON jobs
|
- name: Setup CRON jobs
|
||||||
cron:
|
cron:
|
||||||
name: 'arillso.restic backup {{ item.name }}'
|
name: 'do1jlr.restic_archiver {{ item.name }}'
|
||||||
job: 'CRON=true {{ restic_script_dir }}/backup-{{ item.name }}.sh'
|
job: 'CRON=true {{ restic_script_dir }}/backup-{{ item.name }}.sh'
|
||||||
minute: '{{ item.schedule_minute | default("*") }}'
|
minute: '{{ item.schedule_minute | default("*") }}'
|
||||||
hour: '{{ item.schedule_hour | default("*") }}'
|
hour: '{{ item.schedule_hour | default("*") }}'
|
||||||
weekday: '{{ item.schedule_weekday | default("*") }}'
|
weekday: '{{ item.schedule_weekday | default("*") }}'
|
||||||
month: '{{ item.schedule_month | default("*") }}'
|
month: '{{ item.schedule_month | default("*") }}'
|
||||||
|
cron_file: '/etc/crontab'
|
||||||
state: present
|
state: present
|
||||||
become: true
|
become: true
|
||||||
no_log: true
|
no_log: true
|
||||||
|
|
|
@ -1,30 +1,20 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
# Backup script for {{ item.src|default('stdin') }}
|
# Backup script for {{ item.src|default('stdin') }}
|
||||||
# Use this file to create a Backup and prune existing data with one execution.
|
# This file is to cleanup your backup archive and move some snapshots to a external storage.
|
||||||
|
|
||||||
|
|
||||||
export RESTIC_REPOSITORY={{ restic_repos[item.repo].location }}
|
export RESTIC_REPOSITORY={{ restic_repos[item.repo].location }}
|
||||||
export RESTIC_PASSWORD='{{ restic_repos[item.repo].password | regex_replace('\'', '\'\\\'\'') }}'
|
export RESTIC_PASSWORD='{{ restic_repos[item.repo].password | regex_replace('\'', '\'\\\'\'') }}'
|
||||||
BACKUP_NAME={{ item.name }}
|
BACKUP_NAME={{ item.name }}
|
||||||
{% if restic_repos[item.repo].aws_access_key is defined %}
|
|
||||||
export AWS_ACCESS_KEY_ID={{ restic_repos[item.repo].aws_access_key }}
|
{% if item.src is defined -%}
|
||||||
{% endif %}
|
# BACKUP_SOURCE={{ item.src }}
|
||||||
{% if restic_repos[item.repo].aws_secret_access_key is defined %}
|
{%- endif %}
|
||||||
export AWS_SECRET_ACCESS_KEY='{{ restic_repos[item.repo].aws_secret_access_key | regex_replace('\'', '\'\\\'\'') }}'
|
|
||||||
{% endif %}
|
|
||||||
{% if restic_repos[item.repo].aws_default_region is defined %}
|
|
||||||
export AWS_DEFAULT_REGION={{ restic_repos[item.repo].aws_default_region }}
|
|
||||||
{% endif %}
|
|
||||||
{% if restic_repos[item.repo].b2_account_id is defined %}
|
|
||||||
export B2_ACCOUNT_ID={{ restic_repos[item.repo].b2_account_id }}
|
|
||||||
{% endif %}
|
|
||||||
{% if restic_repos[item.repo].b2_account_key is defined %}
|
|
||||||
export B2_ACCOUNT_KEY={{ restic_repos[item.repo].b2_account_key }}
|
|
||||||
{% endif %}
|
|
||||||
{% if item.src is defined %}
|
|
||||||
BACKUP_SOURCE={{ item.src }}
|
|
||||||
{% endif %}
|
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
|
|
||||||
|
|
||||||
{#
|
{#
|
||||||
Define Tags
|
Define Tags
|
||||||
#}
|
#}
|
||||||
|
@ -37,6 +27,8 @@ set -euxo pipefail
|
||||||
{% macro keep_tags(tags) -%}
|
{% macro keep_tags(tags) -%}
|
||||||
{% if tags is defined and (tags|length>0) %}{% for tag in tags %} --keep-tag {{ tag }}{% endfor %}{% endif %}
|
{% if tags is defined and (tags|length>0) %}{% for tag in tags %} --keep-tag {{ tag }}{% endfor %}{% endif %}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
|
||||||
{#
|
{#
|
||||||
Define Hostname
|
Define Hostname
|
||||||
#}
|
#}
|
||||||
|
@ -103,19 +95,19 @@ else
|
||||||
MODE_TAG="--tag cron"
|
MODE_TAG="--tag cron"
|
||||||
fi
|
fi
|
||||||
{% if item.stdin is defined and item.stdin == true %}
|
{% if item.stdin is defined and item.stdin == true %}
|
||||||
#{{ item.stdin_cmd }} | {{ restic_install_path }}/restic backup \
|
# {{ item.stdin_cmd }} | {{ restic_install_path }}/restic backup \
|
||||||
--stdin $MODE_TAG \
|
# --stdin $MODE_TAG \
|
||||||
{{ tags(item.tags) }} \
|
# {{ tags(item.tags) }} \
|
||||||
{{ stdin_filename(item.stdin_filename) }} \
|
# {{ stdin_filename(item.stdin_filename) }} \
|
||||||
{% if item.exclude is defined %}{{ exclude(item.exclude) }}{% endif %} \
|
# {% if item.exclude is defined %}{{ exclude(item.exclude) }}{% endif %} \
|
||||||
$@
|
# $@
|
||||||
{% else %}
|
{% else %}
|
||||||
#{{ restic_install_path }}/restic backup $BACKUP_SOURCE $MODE_TAG \
|
# {{ restic_install_path }}/restic backup $BACKUP_SOURCE $MODE_TAG \
|
||||||
{{ tags(item.tags) }} \
|
# {{ tags(item.tags) }} \
|
||||||
{% if item.exclude is defined %}{{ exclude(item.exclude) }}{% endif %} \
|
# {% if item.exclude is defined %}{{ exclude(item.exclude) }}{% endif %} \
|
||||||
$@
|
# $@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{#
|
{#
|
||||||
Define stdin forget commands
|
Define stdin forget commands
|
||||||
#}
|
#}
|
||||||
{{ restic_install_path }}/restic forget --path {{ path(item) }} {{ retention_pattern(item) }} {% if item.prune is defined and item.prune == true %}--prune{% endif %}
|
{{ 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