Borg on TrueNAS Scale

Hi,

so, first, a really good job has been done to lock down TrueNAS and not allowing modifications to system path, kudos on that!

Unfortunately, that prevents me from using TrueNAS as Borg repository.

I was using “developer mode” to install borg on TrueNAS, and that is as simple as it can possibly be - enable dev mode, install borg with apt and voilá!

Now I’d wish for a cleaner solution that also is persistent across upgrades, avoiding developer mode (because it is not supported!).

Borgmatic on client system expects “borg” binary to be in the PATH, but PATH variable cannot be changed for non-interactive shell.

In other words, this command works (with standalone borg binary downloaded from internet, not installed via apt)

client# ssh borgbackup@truenas.server /mnt/BACKUP/borg-dir/borg
usage: borg [-V] [-h] [--critical] [--error] [--warning] [--info] [--debug]
…

But this command does not even when ~borgbackup/.bashrc file on Truenas server has PATH updated with /mnt/BACKUP/borg-dir

client# ssh borgbackup@truenas.server borg
bash: line 1: borg: command not found

Installing borg in a docker container is also not great, because I actually want borg to be exposed in TrueNAS.

¯\_(ツ)_/¯

You could use an lxc install Borg in there and mount your storage to the lxc

Works like a charm! Thanks.

How did you managed to access the datasets from TrueNAS?
I try to set up the BorgBackup Web UI (https://www.borgbackupserver.com)
The BorgBackupServer GUI is running (Docker Compose)

I set up a LXC with the borg and the bbs-agent.
I mounted a pool from TrueNAS under /mnt/pool
All folders have the user nobody and the group nogroup
and I can’t access nothing with bbs.

How can I give acces for the files and folders?

try to add the truenas_container_unpriv_root user to the acl list of your dataset.
That buildin truenas user gets mapped to the root user inside the lxc

I already did this, but all folders have the user nobody and the group nogroup.

I have done it differently.
Dataset is owned by borgbackup user and the user is mapped to the same user name in container. see screenshots.


Now I got my borg-backup-server running.
I set it up via docker compose.

For everyone who is interested to set up https://www.borgbackupserver.com here is my

compose.yaml
# Borg Backup Server — Docker Compose
#
# Quick start:
#   1. Copy .env.example to .env and edit it:
#        cp .env.example .env
#   2. Set APP_URL to this machine's hostname or IP (required for agents to connect)
#   3. Start the container:
#        docker compose up -d
#   4. View admin credentials:
#        docker compose logs bbs
#
# All data (database, repositories, SSH keys) is stored in the bbs-data volume.

services:
  bbs:
    image: marcpope/borgbackupserver:latest
    # build: .    # uncomment to build locally instead of pulling from Docker Hub
    container_name: bbs
    ports:
      - ${WEB_PORT:-8080}:80 # Web UI
      - ${SSH_PORT:-2222}:22 # SSH for borg agent connections
    environment:
      - APP_URL=${APP_URL:-http://localhost:8080}
      - SSH_PORT=${SSH_PORT:-2222}
      # Map the app user (www-data) to your host user's UID/GID. Fixes permission
      # issues with bind mounts, especially on btrfs filesystems (e.g. Synology).
      # Changing these after first run triggers an automatic ownership migration.
      # Find your values with: id -u && id -g
      # - PUID=${PUID:-33}
      # - PGID=${PGID:-33}
      # Advanced: remap MariaDB / ClickHouse UIDs too (see .env.example)
      # - MYSQL_PUID=${MYSQL_PUID:-100}
      # - MYSQL_PGID=${MYSQL_PGID:-100}
      # - CH_PUID=${CH_PUID:-999}
      # - CH_PGID=${CH_PGID:-999}
      # Admin password — only used on first run. Omit to auto-generate (shown in logs).
      # - ADMIN_PASS=${ADMIN_PASS}
    volumes:
      - bbs-data:/var/bbs
      # To store backups on a specific disk or path instead of Docker's internal storage,
      # replace the line above with a bind mount:
      # - /mnt/backups:/var/bbs
    restart: unless-stopped
volumes:
  bbs-data: null # Remove this 'volumes' section entirely if using a bind mount above
networks: {}

for the borgbackupserver (bbs) and my

.env
PORT=8081
PUID=568
PGID=568
LOCAL_STORAGE_PATH=/mnt/diskpool-1
TZ=Europe/Berlin

And to access the file on my TrueNAS I also set up the bbs_agent with docker compose.
Here is my

compose.yaml
services:
  bbs-agent:
    image: marcpope/borgbackupserver-agent:latest
    container_name: bbs-agent
    hostname: truenas-home # shown in the BBS UI; set whatever you want
    restart: unless-stopped
    environment:
      BBS_SERVER: ${BBS_SERVER_URL}
      BBS_API_KEY: ${BBS_API_KEY}
    volumes:
      # Persist the SSH key the server issues on first registration.
      # Borg's cache and config also live under this volume, so incremental
      # backups stay fast across container restarts and recreates.
      - ./bbs-agent-config:/etc/bbs-agent
      # Bind-mount the paths you want to back up at the SAME path inside
      # the container. Backup plans in BBS reference these host paths.
      - /mnt/diskpool-1:/mnt/diskpool-1:ro
      - /mnt/diskpool-2:/mnt/diskpool-2:ro
      # Optional: a writable restore target.
      - ./restore:/mnt/restore
    networks:
      - reverse-proxy
volumes:
  bbs-agent-config: null
networks:
  reverse-proxy:
    external: true

for the bbs_agent and the

.env

BBS_SERVER_URL=https://backup.home.mydomain.com
BBS_API_KEY=SECRET-API-KEY