summaryrefslogtreecommitdiff
path: root/playbooks/roles/borg/tasks/main.yml
blob: 3c746e00bdf1bd5ae7889ba8a6de966a5bae2753 (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
30
31
32
33
34
35
36
- name: copy key
  template:
    src: ../templates/borg_ssh_key.j2
    dest: /root/borg_ssh_key
    owner: root
    group: root
    mode: 0600

- name: push borg
  import_role: 
    name: borgbase.ansible_role_borgbackup
  vars:
    borg_encryption_passphrase: "{{ borg_password }}"
    borg_repository: "{{ borg_repo }}"
    borg_user: "{{ borg_my_user }}"
    borg_group: "{{ borg_my_group }}"
    borgmatic_timer: cron
    borg_ssh_command: "ssh -o StrictHostKeyChecking=no -i {{ borg_ssh_key }}"
    borgmatic_relocated_repo_access_is_ok: true
    borg_source_directories:
      "{{ base_files + (extra_files[inventory_hostname] | default([])) }}"
    borg_retention_policy:
      keep_hourly: 3
      keep_daily: 7
      keep_weekly: 4
      keep_monthly: 6
    borgmatic_hooks:
      after_backup:
        - "curl -d '{{ inventory_hostname }}' {{ backup_topic }}"

- name: set archive format to use fqdn
  ansible.builtin.replace:
    path: /etc/borgmatic/config.yaml
    regexp: 'archive_name_format:.*$'
    replace: "archive_name_format: '{fqdn}-{now:%Y-%m-%d-%H%M%S}'"
    backup: yes