mirror of
https://github.com/roles-ansible/ansible_role_restic_archiver.git
synced 2024-08-16 10:09:49 +02:00
Update restic error handling and install cron
This commit is contained in:
parent
e176aa542e
commit
99c9f19403
5 changed files with 54 additions and 3 deletions
19
README.md
19
README.md
|
@ -13,10 +13,14 @@ Of course you don't want to give access to others, so you solve the whole thing
|
||||||
|
|
||||||
As a bonus feature, you can optionally transfer the backups to another disk (even with a different password). Which is also a very charming backup concept from a security point of view.
|
As a bonus feature, you can optionally transfer the backups to another disk (even with a different password). Which is also a very charming backup concept from a security point of view.
|
||||||
|
|
||||||
|
this role does not install restic. For that, we recommend [this ansible role](https://github.com/arillso/ansible.restic.git).
|
||||||
|
We have had good experience with this role for the [restic rest server](https://github.com/donat-b/ansible-restic-rest.git).
|
||||||
|
|
||||||
Variables:
|
Variables:
|
||||||
---------
|
---------
|
||||||
```ini
|
```yml
|
||||||
# which repos should we 'cleanup' by default
|
---
|
||||||
|
# which repos should we cleanup by default
|
||||||
restic_archiver__repos: {}
|
restic_archiver__repos: {}
|
||||||
# - name: example_server:
|
# - name: example_server:
|
||||||
# location: /srv/restic/example_server_repo
|
# location: /srv/restic/example_server_repo
|
||||||
|
@ -52,6 +56,17 @@ restic_archiver__group: 'root'
|
||||||
restic_archiver__hour: '3'
|
restic_archiver__hour: '3'
|
||||||
restic_archiver__minute: '32'
|
restic_archiver__minute: '32'
|
||||||
|
|
||||||
|
# validate if disk is mounted
|
||||||
|
restic_archiver__mount_required: false
|
||||||
|
# which disk have to be mounted
|
||||||
|
restic_archiver__mount_disk: '/mnt/'
|
||||||
|
# umount after use?
|
||||||
|
restic_archiver__umount_after_usage: false
|
||||||
|
|
||||||
|
# required packages
|
||||||
|
restic_archiver__package:
|
||||||
|
- cron
|
||||||
|
|
||||||
# version check for this playbook (true is recomended)
|
# version check for this playbook (true is recomended)
|
||||||
submodules_versioncheck: false
|
submodules_versioncheck: false
|
||||||
```
|
```
|
||||||
|
|
|
@ -35,5 +35,16 @@ restic_archiver__group: 'root'
|
||||||
restic_archiver__hour: '3'
|
restic_archiver__hour: '3'
|
||||||
restic_archiver__minute: '32'
|
restic_archiver__minute: '32'
|
||||||
|
|
||||||
|
# validate if disk is mounted
|
||||||
|
restic_archiver__mount_required: false
|
||||||
|
# which disk have to be mounted
|
||||||
|
restic_archiver__mount_disk: '/mnt/'
|
||||||
|
# umount after use?
|
||||||
|
restic_archiver__umount_after_usage: false
|
||||||
|
|
||||||
|
# required packages
|
||||||
|
restic_archiver__package:
|
||||||
|
- cron
|
||||||
|
|
||||||
# version check for this playbook (true is recomended)
|
# version check for this playbook (true is recomended)
|
||||||
submodules_versioncheck: false
|
submodules_versioncheck: false
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
mode: 0700
|
mode: 0700
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
- name: install cron
|
||||||
|
become: true
|
||||||
|
package:
|
||||||
|
name: "{{ restic_archiver__package }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: setup cronjob for restic
|
- name: setup cronjob for restic
|
||||||
become: true
|
become: true
|
||||||
cron:
|
cron:
|
||||||
|
|
|
@ -48,7 +48,19 @@ set -euxo pipefail
|
||||||
--prune {% endif %}
|
--prune {% endif %}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
{% macro validate_mounts %}
|
||||||
|
{% if restic_archiver__mount_required | bool %}
|
||||||
|
if mountpoint -q {{ restic_archiver__mount_disk }}
|
||||||
|
then
|
||||||
|
echo "{{ restic_archiver__mount_disk }} is mounted"
|
||||||
|
else
|
||||||
|
mount -a
|
||||||
|
fi
|
||||||
|
{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
# Settings for Server {{ repo['name'] | string }}
|
# Settings for Server {{ repo['name'] | string }}
|
||||||
|
{{ validate_mounts }}
|
||||||
export RESTIC_REPOSITORY="{{ repo['location'] }}"
|
export RESTIC_REPOSITORY="{{ repo['location'] }}"
|
||||||
export RESTIC_PASSWORD='{{ repo['password'] | regex_replace('\'', '\'\\\'\'') }}'
|
export RESTIC_PASSWORD='{{ repo['password'] | regex_replace('\'', '\'\\\'\'') }}'
|
||||||
BACKUP_NAME="{{ repo.name }}"
|
BACKUP_NAME="{{ repo.name }}"
|
||||||
|
@ -59,6 +71,7 @@ restic check
|
||||||
|
|
||||||
{% if repo.archive|default(false) %}
|
{% if repo.archive|default(false) %}
|
||||||
# ARCHIVE Settings for Server "{{ repo['name'] | string }}"
|
# ARCHIVE Settings for Server "{{ repo['name'] | string }}"
|
||||||
|
{{ validate_mounts }}
|
||||||
export RESTIC_REPOSITORY="{{ repo['archive_location'] }}"
|
export RESTIC_REPOSITORY="{{ repo['archive_location'] }}"
|
||||||
export RESTIC_PASSWORD='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}'
|
export RESTIC_PASSWORD='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}'
|
||||||
export RESTIC_REPOSITORY2="{{ repo['location'] }}"
|
export RESTIC_REPOSITORY2="{{ repo['location'] }}"
|
||||||
|
@ -71,6 +84,7 @@ if ([ -z "$(restic cat config)" ]) 2>/dev/null; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ARCHIVE Settings for Server "{{ repo['name'] | string }}"
|
# ARCHIVE Settings for Server "{{ repo['name'] | string }}"
|
||||||
|
{{ validate_mounts }}
|
||||||
export RESTIC_REPOSITORY2="{{ repo['archive_location'] }}"
|
export RESTIC_REPOSITORY2="{{ repo['archive_location'] }}"
|
||||||
export RESTIC_PASSWORD2='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}'
|
export RESTIC_PASSWORD2='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}'
|
||||||
export RESTIC_REPOSITORY="{{ repo['location'] }}"
|
export RESTIC_REPOSITORY="{{ repo['location'] }}"
|
||||||
|
@ -82,6 +96,7 @@ restic copy
|
||||||
{% if repo.archive_cleanup %}
|
{% if repo.archive_cleanup %}
|
||||||
|
|
||||||
# ARCHIVE CLEANUP Settings for Server "{{ repo['name'] | string }}"
|
# ARCHIVE CLEANUP Settings for Server "{{ repo['name'] | string }}"
|
||||||
|
{{ validate_mounts }}
|
||||||
export RESTIC_REPOSITORY="{{ repo['archive_location'] }}"
|
export RESTIC_REPOSITORY="{{ repo['archive_location'] }}"
|
||||||
export RESTIC_PASSWORD='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}'
|
export RESTIC_PASSWORD='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}'
|
||||||
BACKUP_NAME="{{ repo.name }}_archive"
|
BACKUP_NAME="{{ repo.name }}_archive"
|
||||||
|
@ -94,3 +109,7 @@ restic check
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
sync
|
||||||
|
{% if restic_archiver__umount_after_usage %}
|
||||||
|
umount restic_archiver__mount_disk
|
||||||
|
{% restic_archiver__mount_disk %}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
---
|
---
|
||||||
playbook_version_number: 24 # should be over ninethousand
|
playbook_version_number: 25 # should be over ninethousand
|
||||||
playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version'
|
playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version'
|
||||||
|
|
Loading…
Reference in a new issue