summaryrefslogtreecommitdiffstats
path: root/roles/ands_backup/tasks/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/ands_backup/tasks/main.yml')
-rw-r--r--roles/ands_backup/tasks/main.yml29
1 files changed, 29 insertions, 0 deletions
diff --git a/roles/ands_backup/tasks/main.yml b/roles/ands_backup/tasks/main.yml
new file mode 100644
index 0000000..16a8ec3
--- /dev/null
+++ b/roles/ands_backup/tasks/main.yml
@@ -0,0 +1,29 @@
+- name: Install required packages
+ package: name={{item}} state=present
+ with_items:
+ - borgbackup
+ - heketi-client
+
+- name: Create scripts directory
+ file: path="{{ ands_script_path }}" state=directory
+
+- name: Populate backup script
+ template: src=backup.sh.j2 dest="{{ ands_script_path }}/ands_backup.sh" owner=root group=root mode=0755
+
+- name: Populate cron job
+ template: src=backup.cron.j2 dest="/etc/cron.d/9ands_backup" owner=root group=root mode=0644
+
+
+- name: Check if backup volume is mounted
+ command: mountpoint -q "{{ ands_backup_volume }}"
+
+
+- block:
+ - name: Check if borg is already initialized
+ stat: path="{{ ands_borg_path }}/config"
+ register: borg_stat_res
+
+ - name: Initialize borg repository
+ shell: "borg init {{ ands_borg_path }} --encryption=none"
+ when: not borg_stat_res.stat.exists
+ run_once: true