mirror of
https://github.com/roles-ansible/ansible_role_restic.git
synced 2024-12-11 23:41:32 +01:00
fix: lvm: Handle cleanup after unreadable files
Before this commit, since restic backup exits with status 3 if it cannot read one or more files, the LVM snapshot wasn't being cleaned up. Now, specially handle the 3 exit status; also, unequivocally perform the LVM cleanup when finished.
This commit is contained in:
parent
de3d35d4ec
commit
6459eaa161
1 changed files with 14 additions and 10 deletions
|
@ -226,27 +226,31 @@ fi
|
||||||
{{ restic_install_path }}/restic backup {% if item.lvm is defined and item.src == '/' %}/rootfs{% endif %}$BACKUP_SOURCE $MODE_TAG \
|
{{ restic_install_path }}/restic backup {% if item.lvm is defined and item.src == '/' %}/rootfs{% endif %}$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 %} \
|
||||||
$@ \
|
$@
|
||||||
{% if item.lvm is defined %}&& cleanup_vol $BACKUP_SOURCE{% endif %};
|
|
||||||
} \
|
} \
|
||||||
{% endif %} {{ backup_output_log }}
|
{% endif %} {{ backup_output_log }}
|
||||||
if [[ $? -eq 0 ]]
|
|
||||||
then
|
case $? in
|
||||||
echo "$(date -u '+%Y-%m-%d %H:%M:%S') OK" {{ backup_result_log }}
|
0)
|
||||||
else
|
echo "$(date -u '+%Y-%m-%d %H:%M:%S') OK" {{ backup_result_log }}
|
||||||
echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" {{ backup_result_log }}
|
;;
|
||||||
|
3)
|
||||||
|
echo "$(date -u '+%Y-%m-%d %H:%M:%S') WARNING" {{ backup_result_log }}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" {{ backup_result_log }}
|
||||||
{% if item.mail_on_error is defined and item.mail_on_error == true %}
|
{% if item.mail_on_error is defined and item.mail_on_error == true %}
|
||||||
mail -s "restic backup failed on {{ ansible_hostname }}" {{ item.mail_address }} <<< "Something went wrong while running restic backup script running at {{ ansible_hostname }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
mail -s "restic backup failed on {{ ansible_hostname }}" {{ item.mail_address }} <<< "Something went wrong while running restic backup script running at {{ ansible_hostname }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||||
{%- if item.src is defined -%}
|
{%- if item.src is defined -%}
|
||||||
{{ ' ' }}We tried to backup '{{ item.src }}'.
|
{{ ' ' }}We tried to backup '{{ item.src }}'.
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{{ ' ' }}Please repair the restic-{{ item.name | replace(' ', '') }} job."
|
{{ ' ' }}Please repair the restic-{{ item.name | replace(' ', '') }} job."
|
||||||
|
{% endif %}
|
||||||
|
esac
|
||||||
|
|
||||||
{% if item.lvm is defined %}
|
{% if item.lvm is defined %}
|
||||||
cleanup_vol $BACKUP_SOURCE
|
cleanup_vol $BACKUP_SOURCE
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{#
|
{#
|
||||||
|
|
Loading…
Reference in a new issue