The problems are actually pretty simple in bash. Bash provides a parameter extension with the removal of the substring, which makes it easy to get the final number from the file name. It has a form ${var##*.}that simply searches to the left of the line until the last occurrence '.', deleting the entire character to and including the point, for example.
var=backup.1
echo ${var
1
, , , - , backup.[0-9]*, max, , ,
max=0
for i in backup.[0-9]*; do
[ "${i##*.}" -gt $max ] && max="${i##*.}"
done
echo "max: $max"
,
max: 3
, .