65 lines
1.7 KiB
YAML
65 lines
1.7 KiB
YAML
---
|
|
- name: 'Configure restic and backup schedule'
|
|
hosts: all
|
|
|
|
vars_files:
|
|
- vars/vars.yml
|
|
- vars/secrets.yml
|
|
|
|
tasks:
|
|
|
|
- name: 'Copy restic shell script'
|
|
ansible.builtin.template:
|
|
src: "files/backups/restic-shell.sh.j2"
|
|
dest: "{{ bin_prefix }}/restic-shell.sh"
|
|
owner: root
|
|
group: root
|
|
mode: "0700"
|
|
|
|
- name: 'Copy restic backup script'
|
|
ansible.builtin.template:
|
|
src: "files/backups/restic-backup.sh.j2"
|
|
dest: "{{ bin_prefix }}/restic-backup.sh"
|
|
owner: root
|
|
group: root
|
|
mode: '0700'
|
|
|
|
- name: 'Create gobackup config directory'
|
|
ansible.builtin.file:
|
|
path: "{{ backup_gobackup_config | dirname }}"
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: 'Copy gobackup config files'
|
|
ansible.builtin.template:
|
|
src: "files/backups/gobackup.yml.j2"
|
|
dest: "{{ backup_gobackup_config }}"
|
|
owner: root
|
|
group: root
|
|
mode: '0700'
|
|
|
|
- name: "Setup paths for backup cron file"
|
|
ansible.builtin.cron:
|
|
cron_file: 'ansible_restic_backup'
|
|
user: 'root'
|
|
env: true
|
|
name: 'PATH'
|
|
job: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin'
|
|
|
|
- name: "Setup mail for backup cron file"
|
|
ansible.builtin.cron:
|
|
cron_file: 'ansible_restic_backup'
|
|
user: 'root'
|
|
env: true
|
|
name: 'MAILTO'
|
|
job: ''
|
|
|
|
- name: "Creates a cron file for backups under /etc/cron.d"
|
|
ansible.builtin.cron:
|
|
name: 'restic backup'
|
|
minute: '0'
|
|
hour: '1'
|
|
job: '/usr/local/bin/restic-backup.sh 2>&1 | logger -t backup'
|
|
cron_file: 'ansible_restic_backup'
|
|
user: 'root'
|