I used to have really bad lower back pain when I would wake up in the morning. I did some research about it online and I read an article suggesting that you stretch out your body and specifically your back before you go to sleep at night. I tried it out and it completely worked.
Now, about 30 minutes before bed, I do about 10 minutes worth of stretching. Most of it has to do with the back but I also do legs, arms and neck. I find that getting my entire body limbered up makes me more relaxed before bed and somehow, I do not completely understand the science, prevents my lower back pain.