Implement borg backup role.
This commit is contained in:
parent
985cc477b5
commit
004919824c
8 changed files with 129 additions and 2 deletions
32
roles/backup/tasks/main.yml
Normal file
32
roles/backup/tasks/main.yml
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue