Closed Tylerjet closed 8 months ago
The script won't detect a file without a file extension right now. We should wrap line 34 - 38 in another if statement like
if [[ ! -d "$path" ]]; then
if [[ ! "$path" =~ \*$ && ! "$path" =~ /$ && ! -f "$path" && ! "$path" =~ \.[^.]+$ ]]; then
path="$path/*"
elif [[ ! "$path" =~ \$ && ! -f "$path" && ! "$path" =~ \.[^.]+$ ]]; then
path="$path*"
fi
fi
Or make the if statement even larger instead of wrapping it.
Example to reproduce (i put echo $file $backup_path
in L49 for more verbose):
pi@mainsailos:~/klipper-backup $ touch /home/pi/printer_data/config/testfile
pi@mainsailos:~/klipper-backup $ cat .env
[...]
path_klipperdata=printer_data/config/testfile
[...]
backup_folder=config/klipperbackup
pi@mainsailos:~/klipper-backup $ ./script.sh
Klipper-backup is not up to date, consider making a git pull to update
cp: cannot stat '/home/pi/printer_data/config/testfile/*': Not a directory
/home/pi/printer_data/config/testfile/* /home/pi/config/klipperbackup
The script can't detect testfile
as a file because it doesn't have any file extension at all, and so testfile
becomes a directory /*
:
/home/pi/printer_data/config/testfile/*