Ansible/playbooks/install_borgbackup.yml

38 lines
1.0 KiB
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 12:29:48 +00:00
borg_backup_name_format: "backup-$(date +%Y-%m-%d-%H:%M)"
borg_backup_compression: "lzma,6"
2024-02-10 12:23:52 +00:00
borg_backup_paths: "/etc /var"
borg_exclude_paths: "--exclude={{borg_repo_path}} --exclude=*.log --exclude=*.log.gz"
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}}"