When someone want to pray all night, his back hurts because of how long he stood. Is he allowed to pray leaning on the wall or would that go against the Sunnah of the Prophet (alaihi As-Salat wa As-Salam)?
It is permitted if you are sick and that your sickness would worsen if you prayed while standing or that the recovery of it would get delayed.
The prophet (SAW) said about praying (it is narrated by al-Bukhaari (1050) from ‘Imraan ibn Husayn):
Pray standing; if you cannot, then sitting; and if you cannot, then lying on your side.
As for your case, you want to do what is called Qiyaam Al-Layl (praying at night as Sunnah) which is permissible, according to the scholars, to pray standing or sitting with no excuse, or to do both. So a person may pray and recite sitting down, and just before doing Rukoo’ he may stand up and recite the rest of the aayahs standing up, then do Rukoo’ and Sujood, then he can do likewise in the second Rak’ah.
It is worth mentioning that if it was permissible to sit for such situations in praying, then it is definitely okay to do it while leaning on a wall which is nearly like standing.