Ansible role do install and setup regular backups with borg-backup

Posted July 19, 2022 by Adrian Wyssmann


Role Summary

Ansible Role Ansible Quality Score Ansible Role GitHub issues GitHub pull requests

Ansible role do install and setup regular backups with borg. The role does the following

  • [Optional] Delete existing repository

  • Initialize a repository at protocol://backup_server:target_dir or target_dir


    In case the repo target_dir already exists, the initalization will be skipped If backup_server is not specified role assumes a local backup i.e. to a local directory

  • Create a systemd service which regularly (accoring to backup_schedule) runs script from

  • There will be an individual borg-script named automatic-backup-{{service_name}}.sh in /opt/borg_backup which is customized with

    • backup_source_dir
    • backup_exclude_file or backup_exclude_list
    • backup_schedule


During the past years I used different tools for backup but ultimately found borg one of the best to use.4