Have one’s back against/to the wall

To be in a defensive or difficult position.

The boy has his back to the wall and must pass his exams or leave school.