I have an update on this.
In order to speed up my tests and allow me to keep more backups I set the automatic backups to only backup courses changed in the last 3 days.
This meant that I backed up only 2 courses. I was then able to set backup_auto_keep to 5.
I ran the backup until I had 5 backups in the Automated backups area of both courses.
The next time I ran the backup the number of backups was reduced to 4 the oldest 2 of my backups where deleted and a new one added.
I ran the backup again and the number of backups remained at 4 with the oldest being deleted and a new one added. This happens every time I run a backup.
So It looks like there is a bug in the script. The logic is wrong some were and the number set in backup_auto_keep is being incremented by -1
The snag is there is not an option for 3 backups so I can only set to keep 1 by using the setting for 2 or 4 by using the setting for 5.