System crashes when uploding file

Dear all

I implemented quite some time ago a script ( oh-bkup.sh), which backs up OH and uploads the backup file to my NAS:

#!/bin/bash
sudo rm /var/lib/openhab/backups/*.zip
sudo rm /home/openhabian/myNAS/*.zip
sudo openhab-cli backup --full
echo Uploading backup to NAS
sudo cp /var/lib/openhab/backups/*.zip /home/openhabian/myNAS

To create I shared folder I wrote to /etc/fstab (this still works):

192.xxx.xxx.xx:/volume2/KNX/Raspberry/mirror /home/openhabian/myNAS nfs rsize=8192,wsize=8192,timeo=14,intr

I executed it via crontab or a rule once a day. Worked fine till OH 4.3. Now backing up (via executing the script, e.g. via ./oh-bkup.sh ) still works fine but when uploading the file to the NAS after some part of uploading the file (e.g. half of backup file size) the system gets stuck and I only can do a hard reboot, i.e. I cannot access OH anymore. Funny enough executing the uploading via cmd line still works, i.e. executing in cmd:

sudo cp /var/lib/openhab/backups/*.zip /home/openhabian/myNAS

Has anybody an idea what the issue could be?

Does it make a difference if you add a delay command of a few seconds before the last line?

edit:
just a tip. If you create the file

/etc/openhab/linux.parameters

and add the following:

OPENHAB_BACKUPS=/home/openhabian/myNAS

all backups will be automatically saved to myNAS

Thank you very much for the tip… Makes life easier! I have changed it as you proposed.

If it works via command line I would expect that it also HAS to work in a script.
Is there any prompt that you need to answer when you execute the command line ?

What if you

  • run the script as user root ?
  • run: bash -x oh-bkup.sh ?
  • running a script as a cronjob I always would make sure that the PATH variable contains all PATHs towards the executables or use PATH/executable to ensure that the executable always is found