mschlenstedt/Loxberry

clone_sd.pl doesn't properly detect directory existence

Opened this issue · 0 comments

Hi all,

I am trying to backup to LoxBerry SD card to an SMB network drive with the script /opt/loxberry/sbin/clone_sd.pl.
I started using the web interface and after it failed tried to debug it on the console but I can't find out what the issue is.

This is what happens when I run the script:

root@loxberry:/opt/loxberry/sbin# perl ./clone_sd.pl /media/smb/qnap.nas/data_ha/Backup/Loxone/loxberry path 7z
================================================================================
<LOGSTART> 07.04.2024 18:23:43 TASK STARTED
<LOGSTART> Clone SD card
<INFO> LoxBerry Version 3.0.1.1 ( is_hwmodel_raspberry_pi_4_400.cfg is_raspberry.cfg is_arch_aarch64.cfg )
<INFO> Loglevel: 6
<INFO> Version of this script: 3.0.0.3
<INFO> Parameters: /media/smb/qnap.nas/data_ha/Backup/Loxone/loxberry path 7z
<INFO> Executing user is root
<INFO> Executing command 'lsblk -b -O -J'...
<OK> Command executed successfully. - Exitcode 0
<INFO> Executing command 'findmnt / -b -J'...
<OK> Command executed successfully. - Exitcode 0
<INFO> Executing command 'findmnt /boot -b -J'...
<OK> Command executed successfully. - Exitcode 0
<INFO> /     is on partition /dev/mmcblk0p2
<INFO> /boot is on partition /dev/mmcblk0p1
<INFO> Boot device is mmcblk0

================================================================================

<INFO> Your boot device (SOURCE of clone):
/dev/mmcblk0 Type disk Size 59.5GB
<INFO>    -> Partition mmcblk0p1 Size 128.0MB VFAT
<INFO>    -> Partition mmcblk0p2 Size 59.4GB EXT4

<CRITICAL> Your entered DESTINATION path /media/smb/qnap.nas/data_ha/Backup/Loxone/loxberry does not exist or isn't writeable.
<LOGEND> Finished
<LOGEND> 07.04.2024 18:23:45 TASK FINISHED

This is the result of some manual permission investigation on the console:

root@loxberry:/opt/loxberry/sbin# stat /media/smb/qnap.nas/data_ha/Backup/Loxone/loxberry
 Datei: /media/smb/qnap.nas/data_ha/Backup/Loxone/loxberry
 Größe: 0               Blöcke: 0          EA Block: 1048576 Verzeichnis
Gerät: 0/44     Inode: 354446      Verknüpfungen: 2
Zugriff: (0777/drwxrwxrwx)  Uid: ( 1001/loxberry)   Gid: ( 1001/loxberry)
Zugriff: 2024-04-07 18:09:49.791597200 +0200
Modifiziert: 2024-04-07 18:09:49.791597200 +0200
Geändert: 2024-04-07 18:09:49.791597200 +0200
Geburt: 2021-11-16 21:33:03.206439200 +0100

root@loxberry:/opt/loxberry/sbin# ls -alF /media/smb/qnap.nas/data_ha/Backup/Loxone/loxberry
insgesamt 2460860
drwxrwxrwx 2 loxberry loxberry          0  7. Apr 18:09 ./
drwxrwxrwx 2 loxberry loxberry          0 25. Aug 2023  ../

root@loxberry:/opt/loxberry/sbin# echo "test" > /media/smb/qnap.nas/data_ha/Backup/Loxone/loxberry/test.txt

root@loxberry:/opt/loxberry/sbin# ls -alF /media/smb/qnap.nas/data_ha/Backup/Loxone/loxberry
insgesamt 2460860
drwxrwxrwx 2 loxberry loxberry          0  7. Apr 18:09 ./
drwxrwxrwx 2 loxberry loxberry          0 25. Aug 2023  ../
-rw-rw-rw- 1 loxberry loxberry          5  7. Apr 18:09 test.txt

root@loxberry:/opt/loxberry/sbin# cat /media/smb/qnap.nas/data_ha/Backup/Loxone/loxberry/test.txt
test

I don't get, why the following block doesn't properly detect existence of that directory...

$destpath_found = 0 if ( !-e $destpath);
if (!$destpath_found) {
    LOGCRIT "Your entered DESTINATION path $destpath does not exist or isn't writeable.";

I forced the script to continue with commenting out the following exit(1); but afterwards there is another issue:

<CRITICAL> Your entered DESTINATION path /media/smb/qnap.nas/data_ha/Backup/Loxone/loxberry does not exist or isn't writeable.
<INFO> Destination device is  () available space 0.0B
<CRITICAL> /media/smb/qnap.nas/data_ha/Backup/Loxone/loxberry (0.0B) is smaller than required space (4.3GB)

Is it possible that the issue is with the fact that it is a network drive (cifs mount) ?
Is there any idea how I can alter the script to make it function ?

Thank you in advance.