diff options
-rwxr-xr-x | borger | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -254,7 +254,8 @@ function borger_single { # Convert the pass command to passphrase otherwise # the user would be interrupted by a passphrase prompt # at every iteration - if [ ! -z "$BORG_PASSCOMMAND" ]; then + if [ ! -z "$BORG_PASSCOMMAND" ] && [ -z "$BORG_PASSPHRASE" ]; then + info "Asking passphrase for borg key used at $DESTINATION" export BORG_PASSPHRASE="`$BORG_PASSCOMMAND`" export BORG_PASSCOMMAND="" fi @@ -281,9 +282,13 @@ function borger_multiple { for config in `ls $CONFIG`; do # Include BORG_PASSPHRASE config for each destination in an array if grep -q "BORG_PASSCOMMAND" $CONFIG/$config; then - COMMAND="`grep BORG_PASSCOMMAND $CONFIG/$config | cut -d = -f 2 | sed -e "s/^'//" -e "s/'$//" -e 's/^"//' -e 's/"$//'`" - #BORG_PASSPHRASES[$config]="BORG_PASSPHRASE=`$COMMAND`" - BORG_PASSPHRASES[$config]="`$COMMAND`" + # Ask the passphrase only once + if [ -z "${BORG_PASSPHRASES[$config]}" ]; then + info "Asking passphrase for borg key used at $config" + COMMAND="`grep BORG_PASSCOMMAND $CONFIG/$config | cut -d = -f 2 | sed -e "s/^'//" -e "s/'$//" -e 's/^"//' -e 's/"$//'`" + #BORG_PASSPHRASES[$config]="BORG_PASSPHRASE=`$COMMAND`" + BORG_PASSPHRASES[$config]="`$COMMAND`" + fi else BORG_PASSPHRASES[$config]="" fi |