I have a hook script (bash shell script) that simply calls autorestic to perform an offsite backup of the locally dumped vzdump files.
If I run my hook script from the command line (and specify job-end) it runs fine and the autorestic job runs:
If I let vzdump run the hook script it fails saying that autorestic can't find ssh in $PATH. You can see in the script output I am dumping $PATH and the output from $(which ssh). So I have access to $PATH and ssh in in the environment path. It seems that when I call autorestic it doesn't not know about $PATH.
My hook script:
If I run my hook script from the command line (and specify job-end) it runs fine and the autorestic job runs:
Code:
Thu May 9 11:45:47 PM UTC 2024 PVE hook script finish (pve01)
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
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/
using parent snapshot 4f2b636e
Files: 0 new, 0 changed, 3 unmodified
Dirs: 0 new, 0 changed, 3 unmodified
Added to the repository: 0 B (0 B stored)
processed 3 files, 268.867 MiB in 0:00
snapshot 08c763d1 saved
Forgetting for location "ext_usb_01"
For backend "storage0"
> Executing: /usr/local/bin/restic forget --tag ar:location:ext_usb_01 --keep-weekly 4 --keep-monthly 3
Applying Policy: keep 4 weekly, 3 monthly snapshots
keep 2 snapshots:
ID Time Host Tags Reasons Paths
---------------------------------------------------------------------------------------------------------
925ca5ed 2024-05-09 22:03:17 pve01 ar:location:ext_usb_01 weekly snapshot /mnt/ext_usb_01/dump
monthly snapshot
08c763d1 2024-05-09 23:47:34 pve01 ar:location:ext_usb_01 weekly snapshot /mnt/ext_usb_01/dump
monthly snapshot
---------------------------------------------------------------------------------------------------------
2 snapshots
remove 1 snapshots:
ID Time Host Tags Paths
---------------------------------------------------------------------------------------
4f2b636e 2024-05-09 23:44:34 pve01 ar:location:ext_usb_01 /mnt/ext_usb_01/dump
---------------------------------------------------------------------------------------
1 snapshots
[0:00] 100.00% 1 / 1 files deleted
Done
Done
Thu May 9 11:47:38 PM UTC 2024 PVE hook script finish (pve01)
If I let vzdump run the hook script it fails saying that autorestic can't find ssh in $PATH. You can see in the script output I am dumping $PATH and the output from $(which ssh). So I have access to $PATH and ssh in in the environment path. It seems that when I call autorestic it doesn't not know about $PATH.
Code:
tail: /mnt/ext_usb_01/pve01.log: file truncated
Thu May 9 23:53:19 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/winter/pve01/: exec: "ssh": executable file not found in $PATH
ext_usb_01@storage0:
Fatal: unable to open repository at sftp:honeyeater-autorestic:/mnt/storage0/winter/pve01/: exec: "ssh": executable file not found in $PATH
exit status 1
Error: 1 errors were found
Thu May 9 23:53:26 UTC 2024 PVE hook script finish (pve01)
My hook script:
Code:
root@pve01:~# cat /etc/vzdump-hook.sh
#!/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