Here is my theory:
You have weak hip flexors, particularly on your right side.
When climbing, there is a greater tendency to pull up in the pedal stroke than when riding in the flats. Because your hip flexors are weak, they cannot fulfill the duty required to pull up the pedal. As a result, your back muscles are engaging and pulling your whole pelvis and hip up. The back muscles, however, weren't designed for that effort, hence the pain.