.
All checks were successful
/ build-docker-image (push) Successful in 51s

This commit is contained in:
2025-09-21 19:50:34 +01:00
parent 9fcd107db8
commit b8d08df128
2 changed files with 58 additions and 31 deletions

View File

@@ -7,6 +7,7 @@
- [borg init repo](#borg-init-repo) - [borg init repo](#borg-init-repo)
- [creating a backup](#creating-a-backup) - [creating a backup](#creating-a-backup)
- [using a bash script](#using-a-bash-script) - [using a bash script](#using-a-bash-script)
- [Using binding volumes](#using-binding-volumes)
- [dev](#dev) - [dev](#dev)
## container image ## container image
@@ -17,16 +18,16 @@
### borg init repo ### borg init repo
```bash ```yaml
services: services:
borg-backup: borg-backup:
image: git.limbosolutions.com/kb/borg-backup:latest image: git.limbosolutions.com/kb/borg-backup:latest
restart: no restart: no
environment: environment:
- BORG_REPO=${BORG_REPO} - BORG_REPO=${BORG_REPO}
- BORG_RSH=${BORG_RSH} - BORG_RSH=ssh -o StrictHostKeyChecking=no -p 2222
- BORG_PASSPHRASE="${BORG_PASSPHRASE}" - BORG_PASSPHRASE="${BORG_PASSPHRASE}"
- MODE=SCRIPT # Valid modes are: BORG, SCRIPT, SHELL, default is BORG - MODE=SHELL # Valid modes are: BORG, SCRIPT, SHELL, default is BORG
configs: configs:
- source: id_ed25519 - source: id_ed25519
@@ -58,9 +59,9 @@ services:
- ./home/user:/mnt/user # Mount local folder to container - ./home/user:/mnt/user # Mount local folder to container
environment: environment:
- BORG_REPO: "?????" - BORG_REPO=${BORG_REPO}
- BORG_RSH: "-o StrictHostKeyChecking=no -o LogLevel=ERROR" - BORG_RSH=ssh -o StrictHostKeyChecking=no -p 2222
- BORG_PASSPHRASE: "????" - BORG_PASSPHRASE="${BORG_PASSPHRASE}"
configs: configs:
- source: id_ed25519 # required for ssh client - source: id_ed25519 # required for ssh client
@@ -73,17 +74,11 @@ services:
configs: configs:
id_ed25519: id_ed25519:
content: | file: ~/.ssh/id_ed25519
-----BEGIN OPENSSH PRIVATE KEY-----
**************
**************
-----END OPENSSH PRIVATE KEY-----
borg_key: borg_key:
content: | content: |
BORG_KEY ??????? ${BORG_KEY}
????????????????
????????????????
``` ```
### using a bash script ### using a bash script
@@ -98,7 +93,7 @@ services:
configs: configs:
- source: backup_script - source: backup_script
target: /backup target: /app/backup-scripts/backup
- source: id_ed25519 - source: id_ed25519
target: /root/.ssh/id_ed25519 target: /root/.ssh/id_ed25519
mode: 0400 mode: 0400
@@ -106,14 +101,15 @@ services:
target: /app/borg/key target: /app/borg/key
mode: 0400 mode: 0400
environment: environment:
BORG_REPO: ssh://user@server/path - BORG_REPO=${BORG_REPO}
BORG_RSH: "ssh -o StrictHostKeyChecking=no" - BORG_RSH=ssh -o StrictHostKeyChecking=no -p 2222
BORG_PASSPHRASE: ***** - BORG_PASSPHRASE="${BORG_PASSPHRASE}"
REPO_SYNC_MAX_SIZE: 10737418240 #10GB - REPO_SYNC_MAX_SIZE=10737418240 #10GB
MODE: - MODE=SCRIPT
volumes: volumes:
- /home/user/repos:/mnt/repos - "./backup-scripts:/app/backup-scripts"
- /home/user/data:/mnt/backup
configs: configs:
# $$ instead of $ so it replaced during runtime and not on docker compose up # $$ instead of $ so it replaced during runtime and not on docker compose up
@@ -157,15 +153,48 @@ configs:
id_ed25519: id_ed25519:
content: | file: ~/.ssh/id_ed25519
-----BEGIN OPENSSH PRIVATE KEY-----
`*****************************´
-----END OPENSSH PRIVATE KEY-----
borg_key: borg_key:
content: | content: |
BORG_KEY ****** ${BORG_KEY}
*************** ```
## Using binding volumes
Creates folder ./backup-scripts
And file ./backup-scripts/backup.
```yaml
services:
borg:
image: git.limbosolutions.com/kb/borg-backup:latest
environment:
- BORG_REPO=${BORG_REPO}
- BORG_RSH=${BORG_RSH}
- BORG_PASSPHRASE="${BORG_PASSPHRASE}"
- MODE=SCRIPT
volumes:
- "./backup-scripts:/app/backup-scripts"
- "/home/mf/repos:/backup/repos"
configs:
- source: id_ed25519
target: /root/.ssh/id_ed25519
mode: 0400
- source: borg_key
target: /app/borg/key
mode: 0400
configs:
id_ed25519:
file: ~/.ssh/id_ed25519
borg_key:
content: |
${BORG_KEY}
``` ```
### dev ### dev

View File

@@ -1,5 +1,3 @@
#/bin/bash #/bin/bash
source loadenv source loadenv
repo_size_bytes=$(remote-connect du -b "$SSH_FOLDER" -d 0) $(remote-connect du -b "$SSH_FOLDER" -d 0 | awk '{print $1}')
repo_size_bytes=$(echo "$repo_size_bytes" | awk '{print $1}')
echo "$repo_size_bytes"