When not in work: weights, or swimming, or rowing - something that strengthens the muscles that you don't hate and will do.
When in work: make sure your desk is set up sensibly and your chair is decent, but if your back still hurts, stand up and work like that.