Implement borg backup role.

This commit is contained in:
Andreas B. Mundt 2020-01-19 18:51:58 +01:00
parent 985cc477b5
commit 004919824c
8 changed files with 129 additions and 2 deletions

View file

@ -0,0 +1,32 @@
- name: install borg
apt:
name: borgbackup
state: latest
- 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 }}"
no_log: True
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 }}"
with_items:
- backup.service
- backup.timer
notify: "enable backup.timer"
- name: run first backup
command: /usr/local/bin/backup
when: not borg.stat.exists