solution-libre / bareos

Docker image for Bareos

Home Page:https://hub.docker.com/r/barcus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bareos

License badge Based OS Based OS Badge amd64 Badge arm64

About

This package provides images for Bareos :

module build size ubuntu size alpine pull
Director Actions Status Size badge Size badge Docker badge
Storage Daemon Actions Status Size badge Size badge Docker badge
Client/File Daemon Actions Status Size badge Size badge Docker badge
webUI Actions Status Size badge Size badge Docker badge
API Actions Status Size badge Docker badge

Images are based on Ubuntu or Alpine, check tags below

👍 Tested with Bareos 16.x.x to 21.0.0

⚠️

  • MySQL/MariaDB backend deprecated since Bareos 20.0.0 (available for old DB only)

  • MySQL/MariaDB backend not available since Bareos 21.0.0

  • SQLite backend deprecated since Bareos 20.0.0

  • Ubuntu images for Bareos 16 and 17 are based on Xenial (deprecated)

  • Ubuntu images for Bareos 18 and 19 are based on Bionic (no more updated)

  • Ubuntu images for Bareos 20 and 21 are based on Focal

  • Alpine images are available for linux/amd64 and linux/arm64/v8 platform

  • Weekly build are deployed to Docker hub on Sunday 4am (GMT+1)

Tags

bareos-director (dir)

  • nightly
  • 21-ubuntu-pgsql, 21-ubuntu, 21, ubuntu, latest
  • 20-ubuntu-pgsql, 20-ubuntu, 20
  • 20-ubuntu-mysql
  • 20-alpine-pgsql, 20-alpine, alpine

⚠️ Deprecated images

  • 19-ubuntu-mysql, 19-ubuntu, 19
  • 19-ubuntu-pgsql
  • 19-alpine-mysql, 19-alpine
  • 19-alpine-pgsql
  • 18-ubuntu-mysql, 18-ubuntu, 18
  • 18-ubuntu-pgsql
  • 18-alpine-mysql, 18-alpine
  • 17-ubuntu-mysql, 17-ubuntu, 17
  • 17-ubuntu-pgsql
  • 17-alpine
  • 16-ubuntu-mysql, 16-ubuntu, 16
  • 16-ubuntu-pgsql

bareos-client (fd) - bareos-storage (sd) - bareos-webui

  • nightly
  • 21-ubuntu, 21, ubuntu, latest
  • 20-ubuntu, 20
  • 20-alpine, alpine

⚠️ Deprecated images

  • 19-ubuntu, 19
  • 19-alpine
  • 18-ubuntu, 18
  • 18-alpine
  • 17-ubuntu, 17
  • 17-alpine
  • 16-ubuntu, 16

bareos-api

  • 21-alpine, 21, alpine, latest

Security advice

The default passwords inside the configuration files are created when building the docker image. Hence for production either build the image yourself using the sources from Github.

⭕ Do not use this container for anything else, as passwords get expose to the Bareos containers.

Setup

Bareos Director requires :

  • PostgreSQL or MySQL as a catalog backend (MySQL deprecated since Bareos 19.0.0)
  • SMTP Daemon as mail router (for reporting)

Bareos Webui requires (Alpine images only) :

  • PHP-FPM

Bareos Client (fd) and Storage (sd) have no dependencies.

Each component have to run in an single container and must linked together through docker-compose, see example below

Requirements

Usage

Define ENV variables required

Declare environment variables or copy the .env.dist to .env and adjust its values.

Remember that all passwords should be defined inside this .env file. It's recommanded to not use default passwords in .env.dist for production usage.

Finaly, be sure to update variables in docker-compose file like ADMIN_MAIL or DB_USER

Run docker-compose

docker-compose -f /path/to/your/docker-compose.yml up -d

docker-compose files are available for Alpine and Ubuntu based stack:

file compose docker latest build
alpine-v1/mysql v3+ v1.13.0+ run-compose
alpine-v2/mysql v3.7+ v18.06.0+ run-compose
ubuntu/mysql v3+ v1.13.0+ run-compose
ubuntu/pgsql v3+ v1.13.0+ run-compose

📁 Those docker-compose file are configured to store data inside /data/(bareos|mysql|pgsql)

Finally, when your containers are up and running access Bareos using WebUI, CLI or API

Access WebUI

Open http://your-docker-host:8080 in your web browser then sign-in

(user: admin / pass: <BAREOS_WEBUI_PASSWORD>)

Access bconsole

docker exec -it bareos-dir bconsole

Access API

(Required Bareos 20+ and Bareos named console)

Open http://your-docker-host:8000/docs in your web browser then click 'Authorize' to sign-in.

Or use curl as example below:

Get token: (should return json object with token inside)

curl -X 'POST' \
  'http://your-docker-host:8000/token' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=&username=admin&password=ThisIsMySecretUIp4ssw0rd&scope=&client_id=&client_secret='

As you can see it uses credentials of Bareos-webui admin user which is configure as a named console in Bareos-director.

Result:

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTY0NzIxMDM3NX0.alKiLsgMrovKVX6fdcUqkhG_9lsJNiOBQ6X7ixyziGw",
  "token_type": "bearer"
}

Then, use this token for example to read all clients configuration (like in bconsole)

curl -X 'GET' \
  'http://your-docker-host:8000/configuration/clients?verbose=yes' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTY0NzIxMDM3NX0.alKiLsgMrovKVX6fdcUqkhG_9lsJNiOBQ6X7ixyziGw'

Should return a JSON file with all clients configuration.

Access metrics for Prometheus

Open http://your-docker-host:9625/metrics in your web browser to display metrics available.

More information about Bareos exporter. Thank you to @vierbergenlars

Metrics should be scraped by Prometheus server.

Official documentation

More information about Bareos configuration and usage in the official documantion

Database migration (MySQL to PostgreSQL)

Since Bareos Version >= 21.0.0 the MySQL database backend is not shipped anymore. Therefore you need to use Bareos 20 to migrate an existing MySQL Bareos Catalog to PostgreSQL. To do so, upgrade to Bareos 20 first and then use this docker-compose file to backup (optional) the whole Bareos MySQL catalog and copy it into a new PostgreSQL catalog database.

If PostgreSQL database is empty or does not exist, it will be created.

⚠️ Don't forget .env file with passwords required!

PostgreSQL database upgrade

Compatibility

At this moment, latest Ubuntu based images are compliant with PostgreSQL 12 or less and Alpine ones with PostgreSQL 14. This is due to the version of pg_dump which is required to dump Bareos database.

Ubuntu images:

  • Bareos v19 -> PostgreSQL v10 or less
  • Bareos v20+ -> PostgreSQL v12 or less

Alpine images:

  • Bareos v19 -> PostgreSQL v13 or less
  • Bareos v20+ -> PostgreSQL v14 or less

Tool

The main idea here is to use postgresql-upgrade Docker image. It will create a new PostgreSQL instance and then use pg_upgrade tool to move all databases from the old instance to the new one.

To proceed, locate your PostgreSQL data folder, according our own docker compose files it could be /data/pgsql/data ! Then identify user used to init the instance. postgres ? pgsql ? root ?

Let's try an exemple with data source /data/pgsql/data and postgres as an admin user.

Finaly run:

docker run -t -i \
  -e PG_NEW=12 \
  -e PGUSER=postgres \
  -v /data/pgsql/data:/pg_old/data \
  -v /data/pgsql-new/data:/pg_new/data \
  barcus/postgresql-upgrade

After sucessful migration, use the new folder /data/pgsql-new/data and the PostgreSQL version related in your docker-compose file.

Build

Docker-compose file

Build your own docker-compose file with this template :

version: '3'
services:
  bareos-dir:
    image: barcus/bareos-director:latest #latest director-pgsql based on ubuntu
    volumes:
      - <BAREOS_CONF_PATH>:/etc/bareos
      - <BAREOS_DATA_PATH>:/var/lib/bareos #required for MyCatalog backup
    environment:
      - DB_INIT=false
      - DB_UPDATE=false
      - DB_HOST=bareos-db
      - DB_PORT=3306
      - DB_NAME=bareos
      - DB_USER=bareos
      - DB_PASSWORD=${DB_PASSWORD} # defined in .env file
      - DB_ADMIN_USER=${DB_ADMIN_USER} # defined in .env file
      - DB_ADMIN_PASSWORD=${DB_ADMIN_PASSWORD} # defined in .env file
      - BAREOS_FD_HOST=bareos-fd
      - BAREOS_FD_PASSWORD=${BAREOS_FD_PASSWORD} # defined in .env file
      - BAREOS_SD_HOST=bareos-sd
      - BAREOS_SD_PASSWORD=${BAREOS_SD_PASSWORD} # defined in .env file
      - BAREOS_WEBUI_PASSWORD=${BAREOS_WEBUI_PASSWORD} # defined in .env file
      - SMTP_HOST=smtpd
      - SENDER_MAIL=your-sender@mail.address #optional
      - ADMIN_MAIL=your@mail.address # Change me!
      # Optional you can get backup notification via Slack or Telegram
      - WEBHOOK_NOTIFICATION=true # true or false if set to true email notification gets disabled
      - WEBHOOK_TYPE=slack # choose slack or telegram
      - WEBHOOK_URL= # set the slack or telegram URL
      - WEBHOOK_CHAT_ID= # for telegram only set the <chat_id>
    depends_on:
      - bareos-db

  bareos-sd:
    image: barcus/bareos-storage:latest
    ports:
      - 9103:9103
    volumes:
      - <BAREOS_CONF_PATH>:/etc/bareos
      - <BAREOS_BKP_VOLUME_PATH>:/var/lib/bareos/storage
    environment:
      - BAREOS_SD_PASSWORD=${BAREOS_SD_PASSWORD} # defined in .env file

  bareos-fd:
    image: barcus/bareos-client:latest
    volumes:
      - <BAREOS_CONF_PATH>:/etc/bareos
      - <BAREOS_DATA_PATH>:/var/lib/bareos-director #required for MyCatalog backup
    environment:
      - BAREOS_FD_PASSWORD=${BAREOS_FD_PASSWORD} # defined in .env file
      - FORCE_ROOT=false

  bareos-webui:
    image: barcus/bareos-webui:latest
    ports:
      - 8080:80
    environment:
      - BAREOS_DIR_HOST=bareos-dir
      - SERVER_STATS=yes #optional enable apache server statistics
    volumes:
      - <BAREOS_CONF_PATH>:/etc/bareos-webui

  #bareos-db:
  #  image: mysql:5.6
  #  volumes:
  #    - <DB_DATA_PATH>:/var/lib/mysql
  #  environment:
  #    - MYSQL_ROOT_PASSWORD=${DB_ADMIN_PASSWORD} # defined in .env file

  bareos-db:
    image: postgres:12
    volumes:
      - <DB_DATA_PATH>:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=${DB_ADMIN_USER} # defined in .env file
      - POSTGRES_PASSWORD=${DB_ADMIN_PASSWORD} # defined in .env file
      - POSTGRES_INITDB_ARGS=--encoding=SQL_ASCII

  bareos-api:
    image: barcus/bareos-api:21
    ports:
    - 8000:8000
    environment:
    - BAREOS_DIR_HOST=bareos-dir

  smtpd:
    image: namshi/smtp

Bareos Director (bareos-dir)

  • <BAREOS_CONF_PATH> is the path to share your Director config folder from the host side (optional/recommended)
  • <BAREOS_DATA_PATH> is the path to share your Director data folder from the host side (recommended)
  • DB_NAME is the bareos database name
  • DB_USER is the bareos database user
  • DB_PASSWORD is the password use to access to the bareos database
  • DB_ADMIN_USER is the password use to initialize bareos user and database
  • DB_ADMIN_PASSWORD is the password use to access to database system
  • SMTP_HOST is the name of smtp container
  • ADMIN_MAIL is your email address
  • SENDER_MAIL is the email address you want to use for send the email (optional, default ADMIN_MAIL value)
  • WEBHOOK_NOTIFICATION=true # true or false if set to true email notification gets disabled
  • WEBHOOK_TYPE=slack # choose slack or telegram
  • WEBHOOK_URL= # set the slack or telegram URL (ex slack: https://hooks.slack.com/services/TXXXXXXXXXX/XXXXXXXXXXX/Cbzi0lUVjKsjiM6kjZL2eQAW)
  • WEBHOOK_CHAT_ID= # for telegram only set the 'chat_id'

Bareos Storage Daemon (bareos-sd)

  • <BAREOS_CONF_PATH> is the path to share your Storage config folder from the host side (optional/recommended)
  • <BAREOS_BKP_VOLUME_PATH> is the path to share your data folder from the host side. (optional)
  • BAREOS_SD_PASSWORD must be same as Bareos Director section

Bareos Client/File Daemon (bareos-fd)

  • <BAREOS_CONF_PATH> is the path to share your Client config folder from the host side (optional/recommended)
  • <BAREOS_DATA_PATH> is the path to access Director data folder (recommended)
  • BAREOS_FD_PASSWORD must be same as Bareos Director section
  • FORCE_ROOT must be true to run Bareos with root permissions

Database MySQL or PostgreSQL (bareos-db)

Required as catalog backend, simply use the official MySQL/PostgreSQL image

  • <DB_DATA_PATH> is the path to share your MySQL/PostgreSQL data from the host side
  • MYSQL_ROOT_PASSWORD is the password for MySQL root user (required for DB init only)
  • POSTGRES_PASSWORD is the password for PostgreSQL root user (required for DB init only)

Bareos webUI (bareos-webui)

  • <BAREOS_CONF_PATH> is the path to share your WebUI config folder from the host side. (optional)
  • default user is admin

⚠️ Remember variables *_HOST must be set with container name

Your own Docker images

Build your own Bareos images :

git clone https://github.com/barcus/bareos
cd bareos
docker build -t director-pqsl:20-alpine director-pgsql/20-alpine
docker build -t storage:20-alpine storage/20-alpine
docker build -t client:20-alpine client/20-alpine
docker build -t webui:20-alpine webui/20-alpine

Build your own Xenial base system image :

git clone https://github.com/rockyluke/docker-ubuntu
cd docker-ubuntu
./build.sh -d xenial

Thanks to @rockyluke :)

Links

For more information visit the Github repositories :

My Docker hub :

Enjoy !

About

Docker image for Bareos

https://hub.docker.com/r/barcus

License:MIT License


Languages

Language:Shell 80.6%Language:Dockerfile 19.4%