Ansible/playbooks/install_borgbackup.yml

35 lines
897 B
YAML
Raw Normal View History

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