autorestic icon indicating copy to clipboard operation
autorestic copied to clipboard

$PATH being ignored by autorestic

Open ilium007 opened this issue 1 month ago • 4 comments

autorestic does not seem to have access to $PATH when calling restic or ssh binaries. I am running a hook script after a Proxmox backup and I have output '$PATH' and $(which ssh) and the ssh binary is in the correct path. It seems that autorestic is ignoring the system $PATH env variable. While I was able to use the --restic-bin option and hard code the restic path (also in an accessible $PATH) it is now falling over on ssh.

Expected behavior

Environment

  • OS: Debian 12
  • Version: [e.g. 22]

Hook script that calls autorestic (and produces output below):

#!/bin/bash

PVE_NODE="$(hostname)"
LOG_FILE="/mnt/ext_usb_01/$PVE_NODE.log"

if [ "$1" == "job-start" ]; then
  printf "$(date) PVE hook script start ($PVE_NODE) - $(pveversion)\n" | tee $LOG_FILE
  printf "PATH: $PATH\n" | tee -a $LOG_FILE
  printf "WHICH SSH: $( which ssh)\n" | tee -a $LOG_FILE
fi

if [ "$1" == "job-end" ]; then
  printf "PATH: $PATH\n" | tee -a $LOG_FILE
  printf "WHICH SSH: $( which ssh)\n" | tee -a $LOG_FILE
  /usr/local/bin/autorestic -c /root/.autorestic.yml --restic-bin /usr/local/bin/restic backup --verbose --all 2>&1 | tee -a $LOG_FILE
  printf "$(date) PVE hook script finish ($PVE_NODE)\n" | tee -a $LOG_FILE
fi

Output:

Thu May  9 23:21:22 UTC 2024 PVE hook script start (pve01) - pve-manager/8.2.2/9355359cd7afbae4 (running kernel: 6.8.4-2-pve)
PATH: /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.
WHICH SSH: /usr/bin/ssh
PATH: /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.
WHICH SSH: /usr/bin/ssh
Using config:    /root/.autorestic.yml
Using lock:      /root/.autorestic.lock.yml


    Backing up location "ext_usb_01"

Backend: storage0
> Executing: /usr/local/bin/restic backup --tag ar:location:ext_usb_01 /mnt/ext_usb_01/dump/
Fatal: unable to open repository at sftp:honeyeater-autorestic:/mnt/storage0/xxx/pve01/: exec: "ssh": executable file not found in $PATH

ext_usb_01@storage0:
Fatal: unable to open repository at sftp:honeyeater-autorestic:/mnt/storage0/xxx/pve01/: exec: "ssh": executable file not found in $PATH
exit status 1

Error: 1 errors were found
Thu May  9 23:21:30 UTC 2024 PVE hook script finish (pve01)

ilium007 avatar May 09 '24 23:05 ilium007