mirror of
https://github.com/roles-ansible/ansible_role_restic_archiver.git
synced 2024-08-16 10:09:49 +02:00
46 lines
1.3 KiB
Django/Jinja
46 lines
1.3 KiB
Django/Jinja
#!/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 }}
|
|
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
|
|
echo "BACKUP: {{ repo.name }}"
|
|
restic check 2>/dev/null
|
|
restic stats 2>/dev/null
|
|
|
|
{% if repo.archive|default(false) %}
|
|
|
|
{% if restic_archiver__mount_required %}
|
|
set +euxo pipefail 2>/dev/null
|
|
if mountpoint -q {{ restic_archiver__mount_disk }}
|
|
then
|
|
echo "{{ restic_archiver__mount_disk }} is mounted"
|
|
else
|
|
mount -a 2>/dev/null
|
|
fi
|
|
set -euxo pipefail 2>/dev/null
|
|
{% endif %}
|
|
|
|
# ARCHIVE Settings for Server "{{ repo['name'] | string }}"
|
|
echo "EXTERNAL_BACKUP: {{ repo.name }}"
|
|
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
|
|
|
|
restic check 2>/dev/null
|
|
restic statps
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
sync
|
|
set +euxo pipefail
|
|
echo "\n\n\n\n"
|
|
df -h
|
|
{% if restic_archiver__umount_after_usage %}
|
|
umount {{ restic_archiver__mount_disk }}
|
|
{% endif %}
|