RESTIC_PASSWORD_COMMAND is unable to evaluate bash script

Hi,

• The output of restic version.

restic 0.16.2 compiled with go1.22rc2 on linux/amd64

• The complete commands that you ran (leading up to the problem or to reproduce the problem).
/usr/local/bin/backup has the following lines,

  export RESTIC_REPOSITORY='/mnt/backup'
  export RESTIC_PASSWORD_COMMAND='/usr/local/bin/repo-password'
  export RESTIC_COMPRESSION='auto'
  export RESTIC_CACHE_DIR=~/.cache/restic

  BACKUP_PATHS="/home /root /etc /var /usr/local/bin /usr/local/sbin /srv /opt"

  mkdir -p "${RESTIC_CACHE_DIR}"

  restic unlock

  restic backup \
         $BACKUP_PATHS \
         --verbose \
         --exclude-file=/etc/restic/excludes.txt \
         --tag scheduled

/usr/local/bin/repo-password has the following lines,

  #!/bin/bash
  echo "My Secure Super Password"

I applied the following after that,

  sudo chmod 744 /usr/local/bin/backup
  sudo chmod 700 /usr/local/bin/repo-password

But I am getting the following error when I am running sudo /usr/local/bin/backup,

Resolving password failed: fork/exec /usr/local/bin/repo-password: exec format error

I don’t know why RESTIC_PASSWORD_COMMAND is unable to run that script and get the string. Any help would be really appreciated. Thank you for the time.

Source: Restic - ArchWiki

Before anything else could you try the same with the latest restic version? It is 0.17.1 now. There is not really any point in investigating maybe already fixed stuff.

2 Likes

What I found after checking that the above script had indentation, and it is making restic to show that error. When I removed it and everything was working as expected. I checked it on 0.17.1 too and the result was identical.

#!/bin/bash
echo "My Secure Super Password"

I think this is a bug, and it should be fixed.

Update: Sorry, it was my mistake, not a bug. I did not know that shell script shouldn’t have indentation (although all lines are equally indented, and it runs fine as standalone script). My Emacs config put auto indentation in the org mode and I pasted the script from there. Anyway, thanks for the support.

1 Like

I agree. Your script should not have indentation before the #! or the echo command.

3 Likes