This project provides a Docker-based solution to host a Borg repository backend for multiple users.
The Docker container expects one or more /config/*.borgusers files to define users and their Borg permissions. These files allow the container to configure users during the startup process.
Here is the template for a .borgusers file:
username1:username1_id
username1_authorized_keys_line_1
username2:username2_id
username2_authorized_keys_line_1
username2_authorized_keys_line_1- The first line specifies the username and the user ID.
- Each subsequent line will be appended to the
~user/.ssh/authorized_keysfile.- Refer to the borgbackup documentation for detailed information on configuring a secure deployment.
- Use an empty line to separate configurations for different users.
Given an example.borgusers file as follow:
user:1001
command="borg serve --storage-quota 10G --restrict-to-repository /home/user/repository",restrict ssh-rsa public_key user.exampleStart the container by mounting the file:
docker run \
-p 2222:22 \
-v ./example.borgusers:/config/example.borgusers:ro \
danielpozza/borgservice:latestThis configuration enables access to the following Borg repository:
ssh://user@IP:2222/home/user/repository
The container checks for host keys in the /host_keys folder. If the folder is empty, new keys will be generated automatically.
Since any path can be specified as a Borg repository destination, ensure the user has the appropriate permissions to access and write to the specified path.
For example: Given an example.borgusers file like this:
user:1001
command="borg serve --storage-quota 10G --restrict-to-repository /repos/user/repo1",restrict ssh-rsa public_key user.exampleCreate the folder with the correct ownership and permissions
mkdir -p ./repos/user
chown 1001:1001 ./repos/userThen, make it accessible through a mount
docker run \
--name borgservice \
-v ./example.borgusers:/config/example.borgusers:ro \
-v ./repos:/repos \
-p 2222:22 \
danielpozza/borgservice:latestHere’s an example compose.yml configuration:
services:
borgbackup:
image: danielpozza/borgservice:latest
container_name: borgservice
volumes:
- ./config.borgusers:/config/config.borgusers:ro
- ./host_keys:/host_keys:ro
- /persistent:/repositories # All the necessary mounts to preserve backups
ports:
- 2222:22Alternatively, run the container directly:
docker run \
--name borgservice \
-v ./example.borgusers:/config/example.borgusers:ro \
-v ./host_keys:/host_keys:ro \
-v /persistent:/repositories \
-p 2222:22 \
danielpozza/borgservice:latest