summaryrefslogtreecommitdiffstats
path: root/roles/ands_backup/tasks/main.yml
blob: 16a8ec363a069c3d2581642c448da60a645791f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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