Rebuild fails: Data directory /shared/postgres_data must not be owned by root

Well, it looks like you worked it out, but it would have been much easier to instead backup on the old server and restore the database on the new one. That way you don’t have to go through the postgres upgrade and you won’t need to muck with permissions. And you wouldn’t need to fool with the indexing and such that you probably didn’t read about in the PostgreSQL 15 update topic.