borg container image feature/review-docker: pipelines and scripts revisions (#1)
All checks were successful
/ build-docker-image (push) Successful in 8s

Co-authored-by: Márcio Fernandes <marcio.fernandes@outlook.pt>
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2025-09-21 19:23:37 +00:00
parent 9fd2b7dd8b
commit 3180d653d3
10 changed files with 254 additions and 129 deletions

View File

@@ -0,0 +1,36 @@
#!/bin/bash
source /app/scripts/loadenv
#fix if its an string instead of an array
IFS=' ' read -r -a rsh_parts <<< "$BORG_RSH"
export BORG_RSH="${rsh_parts[@]}"
case "$MODE" in
BORG)
echo "executing borg cli"
borg "${@:1}" # Forward all arguments except $0 to another CLI so first argument (the name of this scripts don't passthrough)"
;;
SCRIPT)
# check if file exists
if [ ! -f /app/backup-scripts/backup ]; then
cat /app/README.md
exit 1
fi
echo "Executing: backup script with arguments: ${@:1} "
cd /app/backup-scripts && bash backup "${@:1}"
;;
SHELL)
echo "Executing: bash script."
bash -c "${@:1}"
;;
*)
echo "Unknown mode: $MODE."
echo "Valid modes are: BORG, SCRIPT, SHELL"
exit 1
;;
esac

View File

@@ -25,8 +25,7 @@ fi
export SSH_COMMAND="$SSH_COMMAND $SSH_CONNECTION"
: "${MODE:=BORG}" # Set default if MODE is unset to borg cli

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"
echo $(remote-connect du -b "$SSH_FOLDER" -d 0 | awk '{print $1}')