I can confirm this.
I built a new image with DISCOURSE_S3_XXX variables set to enable S3 uploads when the original database was migrated. I would think that this would put all images on S3 from the get-go, but, alas, restoring that backup fails when it tries to migrate to S3.
I then tried to rake uploads:migrate_to_s3 (with all ENV set in the command line before it) and get the infinite loop described in the OP.
I then tried doing a command line restore with all of the DISCOURSE_S3 settings in the command line.
I thought that maybe then I could do a backup and restore, but no. Restore from the web interface fails. Restore from the command line, without passing all of the S3 parameters also fails.
So, it appears that if you want to restore a backup that has uploads in S3, you need to do it from the command line and pass the S3 settings on the command line with the restore.
Not being able to restore a backup that has S3 uploads from the UX seems like a bug.