I have put on 30kg in the last 10 months due to meds and poor diet. I have lower and upper back pain, aching legs, could be due to weight gain?

Yes, see a doctor. It may be due to the weight gain; However it may also be due to another underlying problem; So need to be examined by a doctor ASAP to know what to do;
Weight gain can. Weight gain can certainly explain your symptoms. All your wait is carried by your hips, which can translate into low back pain. Also, your posture changes with weight gain. Also look for other symptoms associated with your back pain: pain or burning during urination, constipation , menses...