Initial commit

This commit is contained in:
2025-02-11 02:40:24 +00:00
commit 9dd06dd647
4 changed files with 60 additions and 0 deletions

13
Dockerfile Normal file
View File

@@ -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"]

19
README.md Normal file
View File

@@ -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@<containter ip>:/opt/borg/<repository name>
```
If you have selected another port other than 22, you can change the port used by borg by running `export BORG_RSH="ssh -p <port>"` 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).

9
docker-compose.yml Normal file
View File

@@ -0,0 +1,9 @@
services:
borg:
image: git.jrdn.dev/jordanwalster/borgbackup:latest
ports:
- 22:22
volumes:
- ./borg:/opt/borg
environment:
- SSH_PASSWORD=value

19
entrypoint.sh Executable file
View File

@@ -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