Ansible/playbooks/install_borgbackup.yml

38 lines
1.0 KiB
YAML

---
- hosts: all
become: yes
vars:
borg_repo_path: "/var/backups/backup.borg/"
borg_repo_encryption: "none"
borg_script_install_path: "/opt/borgbackup.sh"
borg_backup_name_format: "backup-$(date +%Y-%m-%d-%H:%M)"
borg_backup_compression: "lzma,6"
borg_backup_paths: "/etc /var"
borg_exclude_paths: "--exclude={{borg_repo_path}} --exclude=*.log --exclude=*.log.gz"
tasks:
- name: "Install borg backup"
apt:
name: borgbackup
state: latest
- name: "Create backup repository"
ansible.builtin.command: borg init -e {{borg_repo_encryption}} {{borg_repo_path}}
args:
creates: "{{borg_repo_path}}"
- name: "Configure backup script"
ansible.builtin.template:
src: ../templates/borgbackup.j2
dest: "{{borg_script_install_path}}"
owner: root
group: root
mode: '744'
- name: "Configure cronjob"
ansible.builtin.cron:
name: "Borg backup"
minute: "0"
hour: "1"
job: "{{borg_script_install_path}}"