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

I’m trying to migrate discourse from a personal hosting to a Amazon LightSail server. I’ve searched the forum and read all the posts about migrating servers and settings up discourse:

Move your Discourse Instance to a Different Server
Restore a backup from command line
How To Install Discourse on Ubuntu 18.04 | DigitalOcean
discourse/ at master · discourse/discourse · GitHub

As I understand the process is:

  1. Install new Discourse server
  2. Export backup from existing discourse (current the backup is configured to be saved on S3 but I understand this will be manual file backup)
  3. Import backup to new discourse (manually since it can’t pick it up from S3 as I understand)

I’m a little stuck with now to do Step 1 given a few constraint that I have a single domain name and I want to keep the same domain name for the new server and I won’t want any down time (my goal is to complete the new server setup, restore the back and then finally change the DNS entry to point to the new server thereby avoiding any downtime since both server will be running at the same time).

As I understand, when I setup the new Discourse server, I can copy the app.yml from the existing server to the new server and then run discourse-setup. The problem I see here is that when I do this, it’ll use the same DNS name as the existing server (which is what I want) but I foresee two issues here which I’m trying to figure out

  1. The lets-encrypt certificate won’t generate a SSL certificate for the new server since the domain name still points to the old server
  2. Without the SSL certificate (the old server config is set to only use SSL which will be carried over in app.yml) so the server won’t start
  3. I’ve tried connecting to the discourse server by using a DNS name redirection, but if the URL entered doesn’t match the app.yml configuration, either NGINX or Discourse won’t work, you’ll get an error in the browser while trying to connect. So without a web interface I can’t launch the restore process

So how do I complete the setup of the new discourse server using the existing server app.yml and then restore the backup followed by a DNS switch over? OR is there a different easier way to do this?

If you’re not going to use the same S3 bucket then there is a hidden setting that forces the backup to download the S3 files. You can look in the settings file for the name and set it at the rails console. There’s a topic that discusses it, but it might be easiest to look in settings.yml.

You don’t need to run discourse-setup, just copy the app.yml and rebuild.

You can rsync over the let’s encrypt certificates. In fact you can copy over the whole /var/discourse (perhaps excluding some logs and such).


The goal is ideally to “lift n shift” but that’s not possible with amazon lightsail since one cannot import an existing image. So yes it would be using the exact same S3.

It seems like your approach is closest to lift n shift. If I understand what you’re saying, I can just tar/gz the entire /var/discourse folder from the original server and untar it into the new server followed by a discourse start and then just repoint the DNS to the bee server. Is that it? Do I need to rebuild discourse in the new server? What about Nginx, docker and other dependencies outside the folder?

Yes, move the files however makes sense to you. Yes, you’ll need to do a rebuild to build and launch a new container.

1 Like