There are many possibilities...My top considerations include kidney stones with or without frank obstruction. Infection of the kidney which can be precipitated by having stones. I do not know your age, but with pain for so long, one must always consider more concerning things like cancer.
Maybe the old kidney infection
has nothing to do with this new pain. What about an actual back condition or other musculoskeletal diseases like muscle and rib issues.
Bottom line, I think you should see your doctor for further evaluation. 2 years is a long time to go with pain but no assessment.