fix order of restic job hooks

This commit is contained in:
Ryan Cavicchioni 2019-12-25 17:23:36 -06:00
parent 07a5dd96b2
commit e44e06594e
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
2 changed files with 20 additions and 15 deletions

View File

@ -53,7 +53,11 @@ printf "job '%s' started\n" "$JOB"
if [ -d "${HOOKS_PATH}" ]; then
printf "running '%s' job pre-hooks\n" "$JOB"
run-parts -v -a pre "${HOOKS_PATH}"
if ! run-parts --exit-on-error -v -a pre "${HOOKS_PATH}"; then
printf "'%s' pre-hooks failed, running post-hooks and exiting\n" "$JOB"
run-parts --exit-on-error -v -a post "${HOOKS_PATH}"
exit 1
fi
fi
counter=0
@ -86,5 +90,5 @@ fi
if [ -d "${HOOKS_PATH}" ]; then
printf "running '%s' job post-hooks\n" "$JOB"
run-parts -v -a post "${HOOKS_PATH}"
run-parts --exit-on-error -v -a post "${HOOKS_PATH}"
fi

View File

@ -7,18 +7,6 @@
mode: 0755
state: directory
- name: create job hooks
copy:
src: "hooks/{{ hook_item }}"
dest: "{{ restic_etc_path }}/jobs/{{ item.name }}/hooks.d/{{ hook_item | basename | splitext | first }}"
owner: root
group: root
mode: 0755
loop: "{{ item.hooks | default([]) }}"
loop_control:
loop_var: hook_item
when: item.hooks is defined
- name: create job environment helper
template:
src: job-env.sh.j2
@ -27,7 +15,7 @@
group: root
mode: 0400
- name: install hooks
- name: create hooks directory
file:
path: "{{ restic_etc_path }}/jobs/{{ item.name }}/hooks.d"
owner: root
@ -36,6 +24,19 @@
state: directory
when: item.hooks is defined and item.hooks | length
- name: create job hooks
copy:
src: "hooks/{{ hook_item }}"
dest: "{{ restic_etc_path }}/jobs/{{ item.name }}/hooks.d/{{ '%02d' | format(idx) }}-{{ hook_item | basename | splitext | first }}"
owner: root
group: root
mode: 0755
loop: "{{ item.hooks | default([]) }}"
loop_control:
loop_var: hook_item
index_var: idx
when: item.hooks is defined
- name: create job exclude file
template:
src: exclude.txt.j2