I'm wondering if your dog is suffering from some sort of pain - maybe in his back. As he is older, do you know if he suffers from arthritis? Dogs can get that too.
My first thought was that maybe he is having a nightmare, but from what I have read dogs don't usually act this way when they wake from a dream and there is no real way to tell a good dream from a bad one as they react in the same way. Generally, they will wake up and be perfectly fine as if they don't remember dreaming at all, and maybe that is true.
Personally I would take your dog to the vet and have him checked over. If it is joint pain or arthritis he can give him something to ease his pain. You can even buy treats for dogs that help east joint problems.
I really hope he is back to his old self soon.