2024-02-10 11:09:14 +00:00
|
|
|
---
|
|
|
|
- hosts: all
|
|
|
|
become: yes
|
|
|
|
vars:
|
2024-02-10 11:30:43 +00:00
|
|
|
borg_repo_path: "/var/backups/backup.borg/"
|
2024-02-10 11:25:20 +00:00
|
|
|
borg_repo_encryption: "none"
|
|
|
|
borg_backup_paths: "/etc/ /var/spool/ --exclude=*.log"
|
2024-02-10 11:09:14 +00:00
|
|
|
tasks:
|
|
|
|
- name: "Install borg backup"
|
|
|
|
apt:
|
|
|
|
name: borgbackup
|
|
|
|
state: latest
|
|
|
|
|
|
|
|
- name: "Create backup repository"
|
2024-02-10 11:25:20 +00:00
|
|
|
ansible.builtin.command: borg init -e {{borg_repo_encryption}} {{borg_repo_path}}
|
2024-02-10 11:09:14 +00:00
|
|
|
args:
|
2024-02-10 11:30:43 +00:00
|
|
|
creates: "{{borg_repo_path}}"
|
2024-02-10 11:09:14 +00:00
|
|
|
|
|
|
|
- name: "Configure backup script"
|
2024-02-10 11:30:43 +00:00
|
|
|
ansible.builtin.template:
|
2024-02-10 11:09:14 +00:00
|
|
|
src: ../templates/borgbackup.j2
|
|
|
|
dest: /opt/borgbackup.sh
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: '744'
|
|
|
|
|
|
|
|
- name: "Configure cronjob"
|
|
|
|
ansible.builtin.cron:
|
|
|
|
name: "Borg backup"
|
|
|
|
minute: "0"
|
|
|
|
hour: "1"
|
|
|
|
job: "/opt/borgbackup.sh"
|