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

I decided to try again with this process:

rm -rf /var/discourse
rm -rf /var/lib/docker/volumes
docker stop app # on old server - I didn't realize it was still running
rsync -rvzgop root@IP:/var/discourse /var
rsync -rvz root@IP:/var/lib/docker/volumes/ /var/lib/docker/volumes
chown -R messagebus:tss /var/discourse/shared/standalone/postgres_backup
chown -R messagebus:tss /var/discourse/shared/standalone/postgres_data
chown -R messagebus:tss /var/discourse/shared/standalone/postgres_data_older
./launcher rebuild app

This seems to have worked. It produced this output which I now have to decode:

Checking for extension updates                              notice

Your installation contains extensions that should be updated
with the ALTER EXTENSION command.  The file
    update_extensions.sql
when executed by psql by the database superuser will update
these extensions.


Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade.
Once you start the new server, consider running:
    /usr/lib/postgresql/15/bin/vacuumdb --all --analyze-in-stages

Running this script will delete the old cluster's data files:
    ./delete_old_cluster.sh
-------------------------------------------------------------------------------------
UPGRADE OF POSTGRES COMPLETE

Old 13 database is stored at /shared/postgres_data_old

To complete the upgrade, rebuild again using:

./launcher rebuild app
-------------------------------------------------------------------------------------

2aa0a17599100bb507a82e6b420826c135da1e06c9623408aa4579a53ece6cb2

Ah, I just had to run ./launcher rebuild app one more time. The other output about update_extensions.sql etc seems to be from PostgreSQL itself, not Discourse’s upgrade process.

After that second rebuild run, I chose to do a cleanup with ./launcher cleanup and then vacuum/reindex with:

./launcher enter app
su postgres
psql
\connect discourse
REINDEX SCHEMA CONCURRENTLY public;
VACUUM VERBOSE ANALYZE;
\q
exit
exit
1 Like