I’ll just regurgitate what I have read from others then add in some experience.
First is identify the cause.
Bike setup? Particularly saddle position and reach. Too long and you are stretcing which could put pressure on the wrong bit of you. Saddle too high will make you hips wobble and your back hurt. Saddle too low and you are not working effectively. Also consider saddle to far forward or back.
Dodgy hamstrings – connected to lower back pain in some cases.
Lack of core strength – back carrying your weight not your stronger core abdominal muscles.
Injury – see a physio
For me it only really occured on long hard rides (basically races over 30miles)
I started Pilates 12 months ago and haven’t had back pain in the last 10. Pilates also helped me realise some bits of my body weren’t right (tight glutes) and that my hips and pelvis were moving all over the place on the bike. From this I moved my position, ~5mm down and a smidge (yes that is an SI unit) back.