ansible-role-borgbackup/tasks/borg.yml
2023-04-08 23:44:07 +02:00

38 lines
1.2 KiB
YAML

---
- name: "Borg | Copy borgmatic configuration"
ansible.builtin.template:
src: config.yaml.j2
dest: "/etc/borgmatic/{{ borgmatic_config_name }}"
mode: "0600"
- name: "Borg | Add borgmatic 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: "Borg | Init borg repository"
ansible.builtin.expect:
command: "borgmatic init -e {{ borg_repo_key }}"
responses:
^.*want to continue connecting.*$: "yes"
- name: "Borg | Create key export directory"
ansible.builtin.file:
path: "{{ borg_key_export_path }}"
state: directory
mode: "0750"
- name: "Borg | Export repo key"
ansible.builtin.command:
cmd: "borg key export {{ item }} {{ borg_key_export_path }}/{{ item | replace('ssh://', '') | replace('@', '') | replace('.', '_') | replace('/', '') }}"
loop: "{{ borg_repository }}"
- name: "Borg | Save repo key to localhost"
ansible.posix.synchronize:
mode: pull
src: "{{ borg_key_export_path }}"
dest: "~/"