diff --git a/roles/linstor_controller/tasks/install.yml b/roles/linstor_controller/tasks/install.yml index d4cb4bf..da847e1 100644 --- a/roles/linstor_controller/tasks/install.yml +++ b/roles/linstor_controller/tasks/install.yml @@ -42,3 +42,10 @@ systemd: daemon_reload=True when: linctl_unit.changed or (linctl_data_unit is defined and linctl_data_unit.changed) tags: drbd + +- name: Install backup hooks + template: src={{ item }}-backup.j2 dest=/etc/backup/{{ item }}.d/linstor mode=755 + loop: + - pre + - post + tags: drbd diff --git a/roles/linstor_controller/templates/post-backup.j2 b/roles/linstor_controller/templates/post-backup.j2 new file mode 100644 index 0000000..5e181c6 --- /dev/null +++ b/roles/linstor_controller/templates/post-backup.j2 @@ -0,0 +1,8 @@ +#!/bin/bash + +set -eo pipefail + +if [[ -e /home/lbkp/linstor/linstor_backup.zip ]]; then + echo Removing Linstor DB dump /home/lbkp/linstor/linstor_backup.zip + rm -f /home/lbkp/linstor/linstor_backup.zip +fi diff --git a/roles/linstor_controller/templates/pre-backup.j2 b/roles/linstor_controller/templates/pre-backup.j2 new file mode 100644 index 0000000..648c125 --- /dev/null +++ b/roles/linstor_controller/templates/pre-backup.j2 @@ -0,0 +1,18 @@ +#!/bin/bash + +set -eo pipefail + +mkdir -p /home/lbkp/linstor/ + +{% if linctl_ha %} +# Check we are the current active node. Else, just skip the backup +if [[ ! -e /var/lib/linstor/linstordb.mv.db ]]; then + echo Linstor DB not available on this node, skipping backup + exit 0 +fi +{% endif %} + +echo Dumping linstor DB dump +linstor controller backupdb linstor_backup +echo Moving dump to /home/lbkp/linstor/linstor_backup.zip +mv /var/lib/linstor/linstor_backup.zip /home/lbkp/linstor/