ansible-role-borgbackup/tasks/borg.yml

51 lines
1.5 KiB
YAML
Raw Normal View History

2023-04-08 23:02:47 +02:00
---
- name: Ensure /etc/borgmatic exists
ansible.builtin.file:
path: /etc/borgmatic
state: directory
mode: "0700"
owner: "{{ borg_user }}"
group: "{{ borg_group }}"
2023-04-08 23:08:58 +02:00
- name: "Borg | Copy borgmatic configuration"
2023-04-08 23:02:47 +02:00
ansible.builtin.template:
src: config.yaml.j2
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
mode: "0600"
2023-10-17 03:52:16 +02:00
- name: "Borg | Install borgmatic bash completions"
2023-05-08 15:28:47 +02:00
ansible.builtin.shell:
cmd: "borgmatic --bash-completion > /usr/share/bash-completion/completions/borgmatic"
creates: /usr/share/bash-completion/completions/borgmatic
2023-04-08 23:08:58 +02:00
- name: "Borg | Init borg repository"
2023-04-08 23:02:47 +02:00
ansible.builtin.expect:
command: "borgmatic init -e {{ borg_repo_key }} {{ borgmatic_init_options | default([]) }}"
2023-04-08 23:02:47 +02:00
responses:
^.*want to continue connecting.*$: "yes"
2023-04-08 23:20:21 +02:00
- name: "Borg | Create key export directory"
ansible.builtin.file:
path: "{{ borg_key_export_path }}"
state: directory
mode: "0750"
2023-04-08 23:02:47 +02:00
2023-04-08 23:08:58 +02:00
- name: "Borg | Export repo key"
2023-04-08 23:02:47 +02:00
ansible.builtin.command:
2023-04-09 10:23:41 +02:00
cmd: "borg key export {{ item.path }} {{ item.label }}_{{ inventory_hostname }}"
2023-04-09 10:22:21 +02:00
chdir: "{{ borg_key_export_path }}"
2023-04-08 23:02:47 +02:00
loop: "{{ borg_repository }}"
ignore_errors: true
2023-04-08 23:08:58 +02:00
- name: "Borg | Export repo key"
ansible.builtin.command:
cmd: "borg key export ssh://{{ borgbase_repo.repo_id }}@{{ borgbackup_ssh_host }}/./repo borgbase"
chdir: "{{ borg_key_export_path }}"
when: borgbase is defined and borgbase
2023-04-08 23:08:58 +02:00
- name: "Borg | Save repo key to localhost"
2023-04-08 23:44:07 +02:00
ansible.posix.synchronize:
mode: pull
src: "{{ borg_key_export_path }}"
2023-04-08 23:20:21 +02:00
dest: "~/"