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

View File

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