1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_restic_archiver.git synced 2024-08-16 10:09:49 +02:00
ansible_role_restic_archiver/templates/restic_mailsummary.j2

47 lines
1.3 KiB
Text
Raw Normal View History

2020-12-14 16:05:01 +01:00
#!/usr/bin/env bash
# {{ ansible_managed }}
# This file is to cleanup your backup archive and move some snapshots to a external storage.
echo "Summary for Restic Backup"
{% for repo in restic_archiver__repos %}
# Settings for Server {{ repo['name'] | string }}
2020-12-14 16:13:34 +01:00
export RESTIC_REPOSITORY="{{ repo['location'] }}" 2>/dev/null
export RESTIC_PASSWORD='{{ repo['password'] | regex_replace('\'', '\'\\\'\'') }}' 2>/dev/null
BACKUP_NAME="{{ repo.name }}" 2>/dev/null
2020-12-14 16:05:01 +01:00
echo "BACKUP: {{ repo.name }}"
2020-12-14 16:13:34 +01:00
restic check 2>/dev/null
restic stats 2>/dev/null
2020-12-14 16:05:01 +01:00
{% if repo.archive|default(false) %}
{% if restic_archiver__mount_required %}
2020-12-14 16:13:34 +01:00
set +euxo pipefail 2>/dev/null
2020-12-14 16:05:01 +01:00
if mountpoint -q {{ restic_archiver__mount_disk }}
then
echo "{{ restic_archiver__mount_disk }} is mounted"
else
2020-12-14 16:13:34 +01:00
mount -a 2>/dev/null
2020-12-14 16:05:01 +01:00
fi
2020-12-14 16:13:34 +01:00
set -euxo pipefail 2>/dev/null
2020-12-14 16:05:01 +01:00
{% endif %}
# ARCHIVE Settings for Server "{{ repo['name'] | string }}"
echo "EXTERNAL_BACKUP: {{ repo.name }}"
2020-12-14 16:13:34 +01:00
export RESTIC_REPOSITORY="{{ repo['archive_location'] }}" 2>/dev/null
export RESTIC_PASSWORD='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}' 2>/dev/null
BACKUP_NAME="{{ repo.name }}_archive" 2>/dev/null
2020-12-14 16:05:01 +01:00
2020-12-14 16:13:34 +01:00
restic check 2>/dev/null
restic statps
2020-12-14 16:05:01 +01:00
{% endif %}
{% endfor %}
sync
set +euxo pipefail
2020-12-14 16:13:34 +01:00
echo "\n\n\n\n"
2020-12-14 16:05:01 +01:00
df -h
{% if restic_archiver__umount_after_usage %}
umount {{ restic_archiver__mount_disk }}
{% endif %}