Deployment

Everything runs in containers. The host needs a container engine, storage and network access to Microsoft 365. Nothing is installed on the host itself.

Supported hosts

Host OS

Engine

Status

Ubuntu 26.04 LTS

Docker Engine + Compose plugin

Primary

Ubuntu 24.04 LTS

Docker Engine + Compose plugin

Supported

RHEL 9 / 10 (and Alma/Rocky)

Docker CE (Docker’s own repository) + Compose plugin

Supported, not yet tested

Docker only. Podman is not supported (decided 2026-12-03, to keep one engine to test and document). RHEL and its rebuilds run Docker CE from Docker’s repository; install it instead of the Podman that RHEL ships.

Images are built for linux/amd64 and linux/arm64.

Rules that keep it portable between distributions

  • No host dependencies: no host Python, cron, or systemd units required for the Docker path.

  • Compose spec: deploy/compose.yaml uses standard Compose features only, run with the Docker Compose plugin.

  • SELinux: bind mounts are documented with the :Z label for RHEL (enforcing mode stays on); named volumes are the default and need no labels.

  • Non-root: containers run as a fixed UID (10001) with a read-only root filesystem.

  • Fully qualified image names (docker.io/library/postgres:17), so nothing depends on a registry search order.

  • Firewall: only the proxy’s HTTPS port is published (port 80 only if you enable it for Let’s Encrypt); see Network access for ufw and firewalld.

Quick start

On Ubuntu, the installer does all of this: see Install. By hand, the stack is in deploy/ (compose.yaml):

cd deploy
./init.sh backup.example.com     # creates .env and secrets/master_key (never overwrites)
docker compose up -d --build
docker compose ps                # postgres, api (healthy), worker, proxy
curl -k https://backup.example.com/healthz

Services: postgres, a one-shot migrate, api, worker and proxy (Caddy). Application containers run as UID 10001 with a read-only root filesystem, all capabilities dropped and no-new-privileges.

Notes:

  • Back up deploy/secrets/master_key. It encrypts the credentials stored in the database; without it the app registrations must be recreated.

  • secrets/ is mode 0700 and the key file inside is 0644: Compose bind-mounts secret files with their host permissions, and the app’s non-root user must be able to read it.

  • Change the published port with S365B_HTTPS_PORT in .env if 443 is taken.

  • Only HTTPS is published. PostgreSQL, the API and the worker have no published ports; they talk over Compose networks. PostgreSQL is on an internal network with no route out, and the proxy can reach only the API. Caddy’s admin API is off. Publishing anything else (for example PostgreSQL for a database tool) means editing compose.yaml; bind it to 127.0.0.1 and reach it over SSH rather than the network.

  • Port 80 is not published: with Caddy’s local CA it would only redirect to HTTPS. For a Let’s Encrypt certificate (public DNS name), uncomment it in compose.yaml (S365B_HTTP_PORT sets its host port) and remove tls internal from the Caddyfile.

  • S365B_BIND in .env publishes them on one host address only (for example the LAN interface’s IP); the default is every interface.

  • TLS: Caddy uses its own local CA by default (tls internal in deploy/Caddyfile), which suits a LAN-only server.

  • After changing deploy/Caddyfile, run docker compose up -d --force-recreate proxy. The file is bind-mounted on its own, so a container already running keeps the old copy when an editor or rsync/git pull replaces the file.

  • The optional exo-runner service (Exchange Online PowerShell for the setup wizard) will be added to the compose file with the setup wizard.

Scale throughput with docker compose up -d --scale worker=4.

Network access: your responsibility

Mail Safehouse holds a copy of every mailbox it backs up, and credentials that can read (and, through the Restore app, write to) your Microsoft 365 tenant. Securing network access to the server is the responsibility of whoever installs it. The application protects sign-in (Entra ID sign-in, break-glass accounts with two-factor authentication and lockout, an optional network allow-list for break-glass sign-in). It does not limit request rates per address and is not hardened to face the internet.

Recommended:

  • Keep it off the internet. Reach it from the LAN or over a VPN; do not forward its port from your router or cloud firewall.

  • Allow the web port only from the networks that need it, on the host firewall as well as the network’s. Docker publishes ports through its own firewall rules, which bypass both ufw and firewalld zones: restrict the published port with S365B_BIND or the DOCKER-USER chain (below).

  • Restrict SSH to administrators, with keys rather than passwords.

  • Outbound: the server needs HTTPS to Microsoft 365 (graph.microsoft.com, login.microsoftonline.com, outlook.office365.com) and to your mail relay if alerts go by SMTP.

  • Set the break-glass network allow-list (Administration, Sign-in) to your admin networks.

ufw (Ubuntu), allowing only 192.168.1.0/24 to the web UI on 443:

sudo ufw default deny incoming
sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcp
sudo ufw allow from 192.168.1.0/24 to any port 443 proto tcp   # the HTTPS port
sudo ufw enable

firewalld (RHEL):

sudo firewall-cmd --permanent --new-zone=backupadmins
sudo firewall-cmd --permanent --zone=backupadmins --add-source=192.168.1.0/24
sudo firewall-cmd --permanent --zone=backupadmins --add-service=https --add-service=ssh
sudo firewall-cmd --permanent --zone=public --remove-service=ssh
sudo firewall-cmd --reload

These rules protect SSH and anything else on the host, but not the port Docker publishes: Docker inserts its own rules ahead of ufw and firewalld zones. On either distribution, limit it in Docker’s DOCKER-USER chain as well (the port inside the container is 443, whatever S365B_HTTPS_PORT is):

sudo iptables -I DOCKER-USER -p tcp -m conntrack --ctorigdstport 443 --ctdir ORIGINAL \
  ! -s 192.168.1.0/24 -j DROP

Making that rule survive reboots depends on the host (for example iptables-persistent on Ubuntu, or a firewall-cmd --direct rule on RHEL). Simpler where it fits: set S365B_BIND to the address of an interface that only your admin network reaches.

Upgrades and backup of the backup server

  • Database migrations run in the one-shot migrate service on every docker compose up (Alembic, guarded by a PostgreSQL advisory lock); api and worker start only after it succeeds.

  • Planned: s365b db-dump and repository manifests to rebuild the server from scratch on a new host (documented DR runbook).