2022-03-04 14:24:09 +00:00
|
|
|
---
|
|
|
|
# tasks file for borgmatic
|
2022-03-08 13:42:14 +00:00
|
|
|
- name: stat on sources
|
|
|
|
stat:
|
|
|
|
path: "{{ item }}"
|
|
|
|
with_items: "{{ borg_source_directories }}"
|
|
|
|
register: sources_exists
|
|
|
|
|
|
|
|
- name: Assert sources exists
|
|
|
|
assert:
|
|
|
|
that: "{{ item }}.stat.exists"
|
|
|
|
with_items: "{{ sources_exists.results }}"
|
|
|
|
|
2022-03-04 14:24:09 +00:00
|
|
|
- name: Install borg and borgmatic
|
|
|
|
apt:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
with_items:
|
2022-03-08 13:42:14 +00:00
|
|
|
- borgbackup
|
2022-03-04 14:24:09 +00:00
|
|
|
- borgmatic
|
2022-03-08 13:42:14 +00:00
|
|
|
|
|
|
|
- name: Make dir for borgmatic in etc
|
|
|
|
file:
|
|
|
|
path: "/etc/borgmatic"
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: Borgmatic config
|
|
|
|
template:
|
|
|
|
src: borgmatic.config.yaml.j2
|
|
|
|
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
|
|
|
|
mode: 644
|
|
|
|
|
|
|
|
- name: Check borgmatic config
|
|
|
|
command:
|
|
|
|
cmd: validate-borgmatic-config
|
|
|
|
register: validate_borgmatic_config
|
|
|
|
|
|
|
|
- name: Assert that config is validate
|
|
|
|
assert:
|
|
|
|
that: validate_borgmatic_config.failed != true
|
|
|
|
|
|
|
|
- name: copy systemd service
|
|
|
|
template:
|
|
|
|
src: borgmatic.service.j2
|
|
|
|
dest: /etc/systemd/system/borgmatic.service
|
|
|
|
mode: 644
|
|
|
|
notify: reload systemd
|
|
|
|
|
|
|
|
- name: copy systemd timer
|
|
|
|
copy:
|
|
|
|
src: borgmatic.timer
|
|
|
|
dest: /etc/systemd/system/borgmatic.timer
|
|
|
|
notify: "reload systemd"
|
|
|
|
|
|
|
|
- name: enable timer
|
|
|
|
systemd:
|
|
|
|
name: borgmatic
|
|
|
|
enabled: yes
|