How to migrate Discourse from one server to another with the same DNS name

Thanks for the detailed steps, I just had to do something similar, moving to a new host.
Since the site was working, I did not like to go through the backups, so I followed the steps here.

It almost worked but the rebuild on the new host failed.
It turns out the UID/GID mapping was not entirely the same on the two hosts, so when starting Postgres would break due to incorrect ownership of the data folder.

This is something that can happen in other instances as well, but fortunately a fix is available.

There is one extra detail for the scenario in this post, which is that the container is not built, so ./launcher enter app does not work at this stage. As the rebuild would go on for quite some time, I was able to use docker ps to get the name of the container doing the build, and then entering the container:

docker exec -it <container_name> bash
chown -R postgres:postgres /shared/postgres_*

The rebuild then fails (or you cant CTRL+C stop it). After it has stopped, simply run it again, and the permissions are fixed:

./launcher rebuild app

And it is running again :sweat_smile: .

1 Like