trixie/roles/backup/tasks/main.yml

34 lines
768 B
YAML
Raw Normal View History

2020-01-19 18:51:58 +01:00
- name: install borg
apt:
name: borgbackup
2022-06-11 12:42:02 +02:00
state: latest # noqa package-latest
2020-01-19 18:51:58 +01:00
- name: check if borg password is available
stat: path="{{ borg_pwd_file }}"
register: borg
- name: dump borg password
shell: echo -n "{{ borg_pwd }}" > "{{ borg_pwd_file }}" ; chmod 0600 "{{ borg_pwd_file }}"
2022-06-11 12:42:02 +02:00
no_log: true
2020-01-19 18:51:58 +01:00
when: not borg.stat.exists
- name: provide backup script
template:
src: "backup"
dest: "/usr/local/bin/backup"
mode: "0750"
- name: provide backup.service and .timer
copy:
src: "{{ item }}"
dest: "/etc/systemd/system/{{ item }}"
2022-06-11 12:42:02 +02:00
mode: 0644
2020-01-19 18:51:58 +01:00
with_items:
- backup.service
- backup.timer
notify: "enable backup.timer"
- name: run first backup
command: /usr/local/bin/backup
when: not borg.stat.exists