/ansible-role-borg

Role for borgbackup

Primary LanguagePython

Ansible role: borg

Build Status

Ansible role Ansible role downloads Ansible role quality

Ansible role for borgbackup

Requirements

None

Role Variables

Available variables are listed below, along with default values (see defaults/main.yml):

# borg help compression
borg_compression: lz4
# partialy implemented
# https://borgbackup.readthedocs.io/en/stable/usage/init.html
# borg help init
borg_encryption: none

# https://borgbackup.readthedocs.io/en/stable/usage/general.html
borg_remotes:
  default:
    # required
    path: 'ssh://example.org'
    # optional
    compression: "{{ borg_compression }}"
    # Todo handle it
    encryption: "{{ borg_encryption }}"
  # may be string
  db: /path/to/folder

borg_backups:
  -
    # require
    name: minimal
    from:
      - /path/to/from_folder #
    dest: "{hostname}_minimal"
  -
    # require
    name: example
    from:
      - "-" # for stdin
      - /path/to/from_folder # also can add file
    dest: "{hostname}_db_{now:%Y-%m-%dT%H:%M:%S}"
    #optional
    stdin_name: dump.sql
    # By default - true
    before_command: >- # Must be no line!
      /usr/local/bin/command_to_stout_backup

    # defaults
    workdir: '$HOME' # For add to archive by relative path
    remote: db
    user: "{{ ansible_ssh_user }}"

    cron:
      # By default every day 
      minute: "0"
      hour: "1"

      day: "*"
      month: "*"
      weekday: "*"

    prune: true
        cron:
          # https://crontab.guru/
          # By default every day
          minute: "0"
          hour: "0"
          day: "*"
          month: "*"
          weekday: "*"
        # https://borgbackup.readthedocs.io/en/stable/usage/prune.html
        prefix: null
        glob: null
        keep:
            # https://crontab.guru/
            secondly: null
            minutely: null
            hourly: 24
            daily: 14
            weekly: 8
            monthly: -1
    #
    delete: false

Dependencies

Example Playbook

- hosts: all
  roles:
    - role: apkawa.borg

License

MIT

Author Information

Apkawa

Contributing

  1. Install docker
  2. Install pipenv
  3. Initialize pipenv:
    pipenv install --dev
    
  4. Run tests
    pipenv run -- tox -e centos7
    

Low level run part of test

  1. pipenv shell
  2. molecule converge
  3. molecule idempotence
  4. molecule verify for run Testinfra