mirror of
https://github.com/roles-ansible/ansible_role_restic.git
synced 2024-12-11 23:41:32 +01:00
improve error message
This commit is contained in:
parent
a7df28bce9
commit
94aae0e3b9
4 changed files with 28 additions and 5 deletions
|
@ -139,7 +139,7 @@ Available variables:
|
|||
| `scheduled` | no (`false`) | If `restic_create_cron` is set to `true`, this backup is scheduled and tries to create a systemd timer unit. If it fails, it is creating a cronjob. |
|
||||
| `schedule_oncalendar` | ``'*-*-* 02:00:00'`` | The time for the systemd timer. Please notice the randomDelaySec option. By Default the backup is done every night at 2 am (+0-4h). But only if scheduled is true. |
|
||||
| `schedule_minute` | no (`*`) | Minute when the job is run. ( 0-59, *, */2, etc ) |
|
||||
| `schedule_hour` | no (`*`) | Hour when the job is run. ( 0-23, *, */2, etc ) |
|
||||
| `schedule_hour` | no (`2`) | Hour when the job is run. ( 0-23, *, */2, etc ) |
|
||||
| `schedule_weekday` | no (`*`) | Weekday when the job is run. ( 0-6 for Sunday-Saturday, *, etc ) |
|
||||
| `schedule_month` | no (`*`) | Month when the job is run. ( 1-12, *, */2, etc ) |
|
||||
| `exclude` | no (`{}`) | Allows you to specify files to exclude. See [Exclude](#exclude) for reference. |
|
||||
|
|
|
@ -70,9 +70,28 @@
|
|||
- restic_create_cron
|
||||
- item.name is defined
|
||||
- item.scheduled | default(false)
|
||||
|
||||
- name: delete old cronjob entry if available
|
||||
ansible.builtin.cron:
|
||||
name: "do1jlr.restic backup {{ item.name }}"
|
||||
job: "CRON=true {{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh"
|
||||
minute: '{{ item.schedule_minute | default("*") }}'
|
||||
hour: '{{ item.schedule_hour | default("2") }}'
|
||||
weekday: '{{ item.schedule_weekday | default("*") }}'
|
||||
month: '{{ item.schedule_month | default("*") }}'
|
||||
state: absent
|
||||
cron_file: '/etc/crontab'
|
||||
user: 'root'
|
||||
become: true
|
||||
no_log: true
|
||||
with_items: '{{ restic_backups }}'
|
||||
when:
|
||||
- restic_create_cron
|
||||
- item.name is defined
|
||||
- item.scheduled | default(false)
|
||||
when: ansible_service_mgr == 'systemd'
|
||||
rescue:
|
||||
- name: set ceonjo intead of systemd
|
||||
- name: set cronjob intead of systemd
|
||||
set_fact:
|
||||
restic_force_cron: true
|
||||
|
||||
|
@ -82,7 +101,7 @@
|
|||
name: "do1jlr.restic backup {{ item.name }}"
|
||||
job: "CRON=true {{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh"
|
||||
minute: '{{ item.schedule_minute | default("*") }}'
|
||||
hour: '{{ item.schedule_hour | default("*") }}'
|
||||
hour: '{{ item.schedule_hour | default("2") }}'
|
||||
weekday: '{{ item.schedule_weekday | default("*") }}'
|
||||
month: '{{ item.schedule_month | default("*") }}'
|
||||
state: present
|
||||
|
|
|
@ -145,6 +145,10 @@ then
|
|||
else
|
||||
echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" >> {{ forget_result_log }}
|
||||
{% 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 at {{ ansible_hostname }}'
|
||||
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 -%}
|
||||
{{ ' ' }}We tried to backup '{{ item.src }}'.
|
||||
{%- endif -%}
|
||||
{{ ' ' }}Please repair the restic-{{ item.name | replace(' ', '') }} job."
|
||||
{% endif %}
|
||||
fi
|
||||
|
|
|
@ -10,5 +10,5 @@ restic_os_variables:
|
|||
paths:
|
||||
- 'vars'
|
||||
|
||||
playbook_version_number: 10 # should be int
|
||||
playbook_version_number: 11 # should be int
|
||||
playbook_version_path: 'do1jlr.restic.version'
|
||||
|
|
Loading…
Reference in a new issue