commit 9dd06dd6471380400f00a0ad530760159bbcf1cc Author: Jordan Walster Date: Tue Feb 11 02:40:24 2025 +0000 Initial commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..930d9a8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM alpine + +# Install SSH & borg CLI +RUN apk update +RUN apk add openssh +RUN apk add borgbackup + +# Create host keys to allow SSHD to start +RUN ssh-keygen -A + +COPY ./entrypoint.sh /entrypoint.sh + +CMD ["/entrypoint.sh"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..91f16cc --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# borgbackup + +This repository contains the `Dockerfile` and `docker-compose.yml` files for running borg in a docker container. + +## Usage + +To use this container, run the supplied `docker-compose.yml` and substitute the `SSH_PASSWORD` environment variable for one of your choice (This is not your borg passphrase that is used to encrypt your backup). + +### Create your first repository + +Create your first repository against the container using: + +``` +borg init -e repokey borg@:/opt/borg/ +``` + +If you have selected another port other than 22, you can change the port used by borg by running `export BORG_RSH="ssh -p "` on the client running the backup command. + +From here you should follow the usage documentation provided on [borgbackup.readthedocs.io](https://borgbackup.readthedocs.io/en/stable/usage/general.html). diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..51c04c3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + borg: + image: git.jrdn.dev/jordanwalster/borgbackup:latest + ports: + - 22:22 + volumes: + - ./borg:/opt/borg + environment: + - SSH_PASSWORD=value diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..5fa1feb --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# Create backup user +echo "Creating borg backup user" +adduser -D borg + +# Set ssh password +echo "Updating password..." +echo "borg:$SSH_PASSWORD" | chpasswd + +# Change borg folder ownership to be owned by borg +echo "Setting file ownership" +chown -R borg:borg /opt/borg + +# Set default login path to /opt/borg +echo 'cd /opt/borg' >> /home/borg/.profile + +# Start SSHD +/usr/sbin/sshd -D