Back pain is insidious and can be debilitating. It's also quite scary, since the spine is the nerve center of your entire body and damage to it can lead to partial or even complete paralysis. It's not something to be taken lightly, and not something to go the do it yourself route with.
That's why doing yoga for back pain is such a risk unless you've been directly prescriped to do such by a doctor or a licensed chiropractor. While yoga in general is a good idea - it improves muscle tone, increases flexibility and blood flow, and is good for your blood pressure as well - specifically doing yoga for back pain can be a risky proposition. You're not a doctor, so you don't know if your back pain is because of something as simple as having slept wrong and pulled a muscle, or if you've slipped a disc, or even if you have some sort of degenerative condition that yoga will actually exacerbate rather than help. And bear in mind, your body doesn't always register pain when you're abusing it. You may even find yourself in less pain after yoga but actually have done some structural damage. That's the last thing you want.
So now that you're properly warned, it's time to educate yourself on the different kind of yoga for back pain options there are out there. Of course, Yoga itself isn't just one particular set of stretches or poses. There are different kinds practiced in different ways for different reasons, and finding out just which one is best for your aching back or shoulders is a matter of consulting a licensed professional.
That said, most back pain is caused by improper posture. If that's the case for you, then your best starting point is Hatha Yoga, a style and technique of Yoga that focuses on posture as a means of physical purification and restoration. It was created in the 15th century by the Yogi Swatmarama, and he took the word "Hatha" as its descriptor because "ha" means sun and "tha" means moon in sanskrit. The idea was to strike a true, unencumbered balance between the two - just as that should be your goal when practicing yoga for back pain.
Of course, fixing your posture won't do much if you've slipped a disc or some other similarly gruesome injury. That's why you need to be diligent and realistic about what will work for you back pain and what will just make it worse. So remember, step one is see your doctor.