I know this topic firsthand because someone in my circle has to take omeprazole long-term too, and I ended up reading a lot about how paranoid you can get over it. The previous answers are right - it's more nuanced than those horror stories you see everywhere.
The thing is, most long-term studies show: yeah, there are theoretical risks like magnesium or B12 deficiency, and long-term it could potentially affect bone density. But those are potential risks, not guaranteed problems. If your doctor thinks it's necessary, then apparently the risk is lower than the risk of constantly irritating your stomach lining. Two years is quite a while, but if you had serious problems before that would come back without this stuff, then you have to weigh things up.
What I've picked up on: some doctors regularly check whether you can reduce the dose, and do blood tests now and then to catch any deficiencies. Maybe ask your doctor at your next appointment directly whether he's already monitoring this or whether you have a plan to eventually taper off it. That would probably give you more peace of mind than any random internet debates.