home · contact · privacy
Fix borg script. master
authorChristian Heller <c.heller@plomlompom.de>
Tue, 11 Mar 2025 17:39:01 +0000 (18:39 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 11 Mar 2025 17:39:01 +0000 (18:39 +0100)
testing/home/desktop/.local/bin/borgplom

index 95dd580e6a691e828722caa8dcf5b0dedcaa0aaa..277fbb30e2e058b7f67e89e10822dd27fe3742ef 100755 (executable)
@@ -14,6 +14,14 @@ if [ "$1" = "orgpull" ]; then
         fi
         REPO="${NAME_SERVER}:${NAME_REPO}"
         while true; do
+            if [ -z "${BORG_PASSPHRASE}" ]; then
+                stty -echo
+                printf "Borg passphrase: "
+                read passphrase
+                stty echo
+                printf "\n"
+                export BORG_PASSPHRASE="${passphrase}"
+            fi 
             set +e
             ARCHIVES=$(borg list "${REPO}")  # separate step so we may fail early on bad passphrase
             RESULT=$?
@@ -24,12 +32,7 @@ if [ "$1" = "orgpull" ]; then
                 echo "Aborting due to unexpected ${NAME_BORGAPP} error."
                 exit 1
             else
-                stty -echo
-                printf "Borg passphrase: "
-                read passphrase
-                stty echo
-                printf "\n"
-                export BORG_PASSPHRASE="${passphrase}"
+                export BORG_PASSPHRASE=""
             fi
         done
         ARCHIVE=$(echo "${ARCHIVES}" | grep "${NAME_ARCHIVE}" | tail -1 | cut -f1 -d' ')