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

Thanks. Apparently lift n shift wasn’t as clean as I thought, there are a few checks to be done before and after to ensure a smooth lift n shift operation (Postgress was being upgraded from12.0 to 13.0 which taught me a few lessons in the lift n shift process). Here’s a step by step guide for future reference for folks trying to move to a Amazon LightSail server (1GB RAM):

Original Server

  • Create backup to S3
  • cd /var/discourse
  • ./launcher rebuild # get the latest build for an easy transition
  • ./launcher cleanup # clean it up to remove old data and reduce the package size
  • ./launcher stop app # not doing this causes a failure while trying to rebuild it later with Postgres
  • tar -zcvf /var/discourse discourse.tar.gz

New Amazon Light Sail Server

  • Install Ubuntu 20.20 image from Amazon (1GB RAM)
  • Install Docker
  • Create 2GB swap # not doing this may cause rebuild to fail
  • Configure vm.overcommit_memory=1 # not doing this may cause a failure with Postgres during a rebuild
  • FTPS/transfer discourse.tar.gz from original server
  • tar -zxvf discourse.tar.gz -C /
  • cd /var/discourse
  • Set UNICORN_WORKERS in app.yml to 2 # increasing it beyond 2 with 1GB RAM will risk swapping and throttling it due to excessive disk activity
  • ./launcher rebuild
  • Change DNS to point to new Amazon server

Is there an easier way to migrate servers (lift n shift) without having to go through a discourse setup process?

1 Like