Skip to content

robertdebock/ansible-role-bareos_dir

Install and configure Bareos Director.

GitHub GitLab Downloads Version
github gitlab downloads Version

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

---
- name: Converge
  hosts: all
  become: true
  gather_facts: true

  roles:
    - role: robertdebock.bareos_dir
      bareos_dir_backup_configurations: true
      bareos_dir_install_debug_packages: true
      bareos_dir_catalogs:
        - name: MyCatalog
          dbname: bareos
          dbuser: bareos
          dbpassword: ""
      bareos_dir_consoles:
        - name: bareos-mon
          description: "Restricted console used by tray-monitor to get the status of the director."
          password: "MySecretPassword"
          commandacl:
            - status
            - .status
          jobacl:
            - "*all"
      bareos_dir_clients:
        - name: bareos-fd
          address: 127.0.0.1
          password: "MySecretPassword"
          maximum_concurrent_jobs: 3
          heartbeat_interval: 60
        - name: "disabled-client"
          enabled: false
      bareos_dir_filesets:
        - name: LinuxAll
          description: "Backup all regular filesystems, determined by filesystem type."
          include:
            files:
              - /
            exclude_dirs_containing: nobackup
            options:
              signature: MD5
              one_fs: false
              fs_types:
                - btrfs
                - ext2
                - ext3
                - ext4
                - reiserfs
                - jfs
                - vfat
                - xfs
                - zfs
              compression: GZIP
          exclude:
            files:
              - /var/lib/bareos
              - /var/lib/bareos/storage
              - /proc
              - /tmp
              - /var/tmp
              - /.journal
              - /.fsck
        - name: disabled-fileset
          enabled: false
      bareos_dir_jobdefs:
        - name: DefaultJob-1
          type: Backup
          level: Incremental
          fileset: SelfTest
          schedule: WeeklyCycle
          storage: File-1
          messages: Standard
          pool: Full
          priority: 10
          write_bootstrap: "/var/lib/bareos/%c.bsr"
          full_backup_pool: Full
          differential_backup_pool: Differential
          incremental_backup_pool: Incremental
        - name: "disabled-jobdef"
          enabled: false
      bareos_dir_jobs:
        - name: my_job
          description: "My backup job"
          pool: Full
          type: Backup
          client: bareos-fd
          fileset: LinuxAll
          storage: File-1
          messages: Standard
        - name: disabled_job
          enabled: false
        - name: BackupCatalog
          description: "Backup the catalog database (after the nightly save)"
          jobdefs: DefaultJob
          level: Full
          fileset: Catalog
          client: bareos-fd
          schedule: WeeklyCycleAfterBackup
          runbeforejob: "/usr/lib/bareos/scripts/make_catalog_backup MyCatalog"
          runafterjob: "/usr/lib/bareos/scripts/delete_catalog_backup MyCatalog"
          write_bootstrap: '|/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \" -s \"Bootstrap for Job %j\" root'
          priority: 11
          maximum_concurrent_jobs: 2
      bareos_dir_messages:
        - name: "Standard"
          description: "Send relevant messages to the Director."
          append:
            - file: "/var/log/bareos/bareos.log"
              messages:
                - all
                - "!skipped"
                - "!terminate"
          catalog:
            - all
            - "!skipped"
            - "!saved"
            - "!audit"
          console:
            - all
            - "!skipped"
            - "!saved"
        - name: "disabled-message"
          enabled: false
        - name: Daemon
          description: "Message delivery for daemon messages (no job)."
          mailcommand: '/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos daemon message\" %r'
          mail:
            - to: root
              messages:
                - all
                - "!skipped"
                - "!audit"
          console:
            - all
            - "!skipped"
            - "!saved"
            - "!audit"
          append:
            - file: "/var/log/bareos/bareos.log"
              messages:
                - all
                - "!skipped"
                - "!audit"
            - file: "/var/log/bareos/bareos-audit.log"
              messages:
                - audit
        - name: RestoreFiles
          description: "Standard Restore template. Only one such job is needed for all standard Jobs/Clients/Storage ..."
          type: Restore
          client: bareos-fd
          fileset: LinuxAll
          storage: File-1
          pool: Incremental
          messages: Standard
          where: "/tmp/bareos-restores"
      bareos_dir_pools:
        - name: Full
          pool_type: Backup
          recycle: true
          autoprune: true
          volume_retention: 365 days
          maximum_volume_bytes: 50G
          maximum_volumes: 100
          label_format: "Full-"
        - name: "disabled-pool"
          enabled: false
      bareos_dir_profiles:
        - name: webui-admin
          jobacl:
            - "*all*"
          clientacl:
            - "*all*"
          storageacl:
            - "*all*"
          scheduleacl:
            - "*all*"
          poolacl:
            - "*all*"
          commandacl:
            - "!.bvfs_clear_cache"
            - "!.exit"
            - "!.sql"
            - "!configure"
            - "!create"
            - "!delete"
            - "!purge"
            - "!prune"
            - "!sqlquery"
            - "!umount"
            - "!unmount"
            - "*all*"
          filesetacl:
            - "*all*"
          catalogacl:
            - "*all*"
          whereacl:
            - "*all*"
          pluginoptionsacl:
            - "*all*"
        - name: "disabled-message"
          enabled: false
      bareos_dir_schedules:
        - name: WeeklyCycle
          run:
            - Full 1st sat at 21:00
            - Differential 2nd-5th sat at 21:00
            - Incremental mon-fri at 21:00
        - name: WeeklyCycleAfterBackup
          description: This schedule does the catalog. It starts after the WeeklyCycle.
          run:
            - Full mon-fri at 21:10
        - name: "disabled-schedule"
          enabled: false
      bareos_dir_storages:
        - name: File-1
          address: dir-1
          password: "MySecretPassword"
          device: FileStorage
          media_type: File
          tls_enable: true
          tls_verify_peer: false
          maximum_concurrent_jobs: 3
        - name: "disabled-storage"
          enabled: false

The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml:

---
- name: Prepare
  hosts: all
  become: true
  gather_facts: false

  roles:
    - role: robertdebock.bootstrap
    # The roles buildtools, python_pip and postgres are required.
    # bareos-dir needs to connect to a database.
    - role: robertdebock.buildtools
    - role: robertdebock.postgres
    # The roles core_dependencies and postfix are  required for the `bareos_role`: "dir".
    # bareos-dir needs to send emails.
    - role: robertdebock.core_dependencies
    - role: robertdebock.postfix
      postfix_myhostname: "smtp.example.com"
      postfix_mydomain: "example.com"
      postfix_myorigin: "example.com"
    - role: robertdebock.bareos_repository
      bareos_repository_enable_tracebacks: true

Also see a full explanation and example on how to use these roles.

The default values for the variables are set in defaults/main.yml:

---
# defaults file for bareos_dir

# The director has these configuration parameters.

# Backup the configuration files.
bareos_dir_backup_configurations: false

# Install debug packages. This requires the debug repositories to be enabled.
bareos_dir_install_debug_packages: false

# The hostname of the Director.
bareos_dir_hostname: "{{ inventory_hostname }}"

# The password for the Director.
bareos_dir_password: "secretpassword"

# The query file.
bareos_dir_queryfile: "/usr/lib/bareos/scripts/query.sql"

# The maximum number of concurrent jobs.
bareos_dir_max_concurrent_jobs: 100

# The messages configuration to use.
bareos_dir_message: Daemon

# Enable TLS.
bareos_dir_tls_enable: true

# Verify the peer.
bareos_dir_tls_verify_peer: false

# A list of catalogs to configure.
bareos_dir_catalogs: []

# A list of consoles to configure.
bareos_dir_consoles: []

# A list of counters to configure.
bareos_dir_counters: []

# A list of clients to configure.
bareos_dir_clients: []

# A list of filesets to configure.
bareos_dir_filesets: []

# A list of jobdefs to configure
bareos_dir_jobdefs: []

# A list of jobs to configure.
bareos_dir_jobs: []

# A list of messages to configure.
bareos_dir_messages: []

# A list of pools to configure.
bareos_dir_pools: []

# A list of profiles to configure.
bareos_dir_profiles: []

# A list of schedules to configure.
bareos_dir_schedules: []

# A list of storages to configure.
bareos_dir_storages: []

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub GitLab
robertdebock.bootstrap Build Status GitHub Build Status GitLab
robertdebock.bareos_repository Build Status GitHub Build Status GitLab
robertdebock.buildtools Build Status GitHub Build Status GitLab
robertdebock.python_pip Build Status GitHub Build Status GitLab
robertdebock.postgres Build Status GitHub Build Status GitLab
robertdebock.core_dependencies Build Status GitHub Build Status GitLab
robertdebock.postfix Build Status GitHub Build Status GitLab

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles: dependencies

This role has been tested on these container images:

container tags
Debian bookworm, bullseye
EL 9
Fedora 38, 39
Ubuntu jammy

The minimum version of Ansible required is 2.12, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

If you find issues, please register them in GitHub.

Apache-2.0.

robertdebock

Please consider sponsoring me.