This repository has been archived on 2023-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
max/roles/borg/tasks/main.yml

39 lines
1.1 KiB
YAML
Raw Normal View History

2023-01-10 22:55:25 +00:00
- name: Install borg
apt:
pkg:
- borgbackup
- borgmatic
- name: Create borg service directory
file:
path: "{{ service_dir }}"
state: directory
- name: Copy borg backup configuration
2023-01-11 00:04:13 +00:00
template:
src: "{{ role_path }}/templates/backup.yml.j2"
2023-01-10 22:55:25 +00:00
dest: "{{ service_dir }}/backup.yml"
- name: Copy private key
copy:
src: "{{ role_path }}/files/id_ed25519"
dest: "{{ service_dir }}/id_ed25519"
mode: 0600
- name: Copy systemd timer backup service
2023-01-11 00:04:13 +00:00
template:
src: "{{ role_path }}/templates/backup.service.j2"
2023-01-10 22:55:25 +00:00
dest: "/etc/systemd/system/backup.service"
register: service
- name: Copy systemd timer backup timer
copy:
src: "{{ role_path }}/files/backup.timer"
dest: "/etc/systemd/system/backup.timer"
register: timer
- name: Enable systemd timer
systemd:
name: backup.timer
enabled: true
state: started
daemon_reload: "{{ 'yes' if service.changed or timer.changed else 'no' }}"
2023-01-20 23:09:26 +00:00
- name: Restore backup
command:
cmd: "borgmatic extract --archive latest --destination / --config {{ service_dir }}/backup.yml"
creates: /data