I have a script in a container that I want to execute when doing a backup.
If I manually execute the script from the node CLI using:
pct exe <id> -- ./script.sh
The script runs as expected.
The problem is when I put the exact same command in my hook script, I get an execution error:
INFO: Stop daemon for 4000 backup
INFO: lxc-attach: 4000: attach.c: lxc_attach_run_command: 1503 No such file or directory - Failed to exec "./stopmn.sh"
ERROR: Backup of VM 4000 failed - command '/root/backup-hook.sh backup-start stop 4000' failed: exit code 127
INFO: Failed at 2020-04-18 17:36:03
INFO: Backup job finished with errors
TASK ERROR: job errors
Any help with this would be appreciated,,,
Here is the hook script:
#!/bin/bash
if [ "$1" == "backup-start" ] && [ ${VMTYPE} == "lxc" ]; then
echo "Running pre backup guest update/upgrade for $3"
pct exec "$3" -- bash -c "apt-get update -y && apt-get upgrade -y"
echo "Running pre backup guest cleanup for $3"
pct exec "$3" -- bash -c "apt-get clean"
echo "Stop daemon for $3 backup"
pct exec "$3" -- ./stopmn.sh
fi
If I manually execute the script from the node CLI using:
pct exe <id> -- ./script.sh
The script runs as expected.
The problem is when I put the exact same command in my hook script, I get an execution error:
INFO: Stop daemon for 4000 backup
INFO: lxc-attach: 4000: attach.c: lxc_attach_run_command: 1503 No such file or directory - Failed to exec "./stopmn.sh"
ERROR: Backup of VM 4000 failed - command '/root/backup-hook.sh backup-start stop 4000' failed: exit code 127
INFO: Failed at 2020-04-18 17:36:03
INFO: Backup job finished with errors
TASK ERROR: job errors
Any help with this would be appreciated,,,
Here is the hook script:
#!/bin/bash
if [ "$1" == "backup-start" ] && [ ${VMTYPE} == "lxc" ]; then
echo "Running pre backup guest update/upgrade for $3"
pct exec "$3" -- bash -c "apt-get update -y && apt-get upgrade -y"
echo "Running pre backup guest cleanup for $3"
pct exec "$3" -- bash -c "apt-get clean"
echo "Stop daemon for $3 backup"
pct exec "$3" -- ./stopmn.sh
fi