I am not sure about this one, it might be a problem with capability reloading after deleting of old role assignments.
To replicate (did not test it now, just what I remember from testing creator role):
1/ backup course
2/ restore into existing course - overriding data
3/ no roles assigned at all - though there is a test that should assign legacy editing teacher
My +1 to remember the old role of the user that is restoring the course and reassign it if he/she does not have role assign capability in restored course. I would not use the $CFG->creatornewroleid for this case.