This is a tough one. One possible explanation is back spasms which can happen to anyone, at any time. However, these tend to occur more in the lower than the upper back. Other explanations include muscle irritation and nerve issues (radiculopathies). These tend to be rare in the thoracic (or upper spine), which is where the problem would need to be to account for upper and middle back pain. I suggest you see your doctor, and perhaps a thorough physical exam, MRI ± visit to a neurologist might help sort out this issue.