Avoid triggers that can cause back spasms to eliminate the main cause of your back pain. Stress and caffeine are triggers that you can control, as are lack of sleep, low sodium count in your body, and anxiety. If you get a back spasm, place a heating pad on your back and get some rest.
One of the leading causes of back pain actually seems like one of the most harmless jobs. This is having a desk job and sitting in front of a computer all day. Your posture is probably very bad at this job and you do not get much movement, leading to back pain.