diff --git a/roles/nomad/tasks/install.yml b/roles/nomad/tasks/install.yml index a8df09f..b3280b4 100644 --- a/roles/nomad/tasks/install.yml +++ b/roles/nomad/tasks/install.yml @@ -53,3 +53,9 @@ when: nomad_unit.changed tags: nomad +- name: Install backup hooks + template: src={{ item }}-backup.j2 dest=/etc/backup/{{ item }}.d/nomad mode=755 + loop: + - pre + - post + tags: nomad diff --git a/roles/nomad/templates/post-backup.j2 b/roles/nomad/templates/post-backup.j2 new file mode 100644 index 0000000..1528a95 --- /dev/null +++ b/roles/nomad/templates/post-backup.j2 @@ -0,0 +1,5 @@ +#!/bin/sh + +set -eo pipefail + +rm -f {{ nomad_root_dir }}/backup/nomad.snap diff --git a/roles/nomad/templates/pre-backup.j2 b/roles/nomad/templates/pre-backup.j2 new file mode 100644 index 0000000..113fb58 --- /dev/null +++ b/roles/nomad/templates/pre-backup.j2 @@ -0,0 +1,5 @@ +#!/bin/sh + +set -eo pipefail + +{{ nomad_root_dir }}/bin/nomad operator snapshot save {{ nomad_root_dir }}/backup/nomad.snap