ansible-role-borgbackup/tasks/borgmatic.yml

32 lines
1,005 B
YAML
Raw Normal View History

2023-04-08 23:02:47 +02:00
---
- name: "Borgamtic | Copy configuration"
ansible.builtin.template:
src: config.yaml.j2
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
mode: "0600"
- name: "Borgmatic | Add cron job"
ansible.builtin.cron:
name: "{{ borgmatic_timer_cron_name }}"
hour: "{{ borgmatic_timer_hour }}"
minute: "{{ borgmatic_timer_minute }}"
user: "{{ borg_user }}"
cron_file: "{{ borgmatic_timer_cron_name }}"
job: "borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
- name: "Borgmatic | Init borg repository"
ansible.builtin.expect:
command: "borgmatic init -e {{ borg_repo_key }}"
responses:
^.*want to continue connecting.*$: "yes"
- name: "Borgmatic | Create backup"
ansible.builtin.command:
cmd: "borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }}"
- name: "Borgmatic | Export repo key"
ansible.builtin.command:
cmd: "borg key export {{ item }} > {{ borg_key_export_path }}"
loop: "{{ borg_repository }}"
delegate_to: localhost