diff --git a/README.md b/README.md index 5938933..7e23eaf 100644 --- a/README.md +++ b/README.md @@ -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 ??????? - ???????????????? - ???????????????? + content: | + ${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 diff --git a/docker/app/scripts/remote-get-folder-size b/docker/app/scripts/remote-get-folder-size index d02b5c6..d1a4f0e 100755 --- a/docker/app/scripts/remote-get-folder-size +++ b/docker/app/scripts/remote-get-folder-size @@ -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" \ No newline at end of file +$(remote-connect du -b "$SSH_FOLDER" -d 0 | awk '{print $1}') \ No newline at end of file