Upgrade Discourse

It is strongly recommended to create a backup before starting the update process. If you have important data, create and try to restore a backup to ensure that everything works properly.

Migrating the database

Follow the steps below to migrate the database from an old version to a new one:

  • Create a database backup of the running application with the following command:

    $ pg_dump -U postgres bitnami_discourse > backup.sql
  • Create a tarball with the uploaded files of the running application:

    $ tar -czvf uploads.tar.gz /opt/bitnami/apps/discourse/htdocs/public/uploads
  • Copy both backups to the server hosting the new version.

  • On the new server, stop all servers and start only PostgreSQL:

    $ sudo /opt/bitnami/ stop
    $ sudo /opt/bitnami/ start postgresql
  • Remove the previous database:

    $ psql -U postgres
    drop database bitnami_discourse;
    create database bitnami_discourse;
    alter database bitnami_discourse owner to bn_discourse;
    create extension hstore; create extension pg_trgm;
  • Restore the new database:

    $ psql -U postgres bitnami_discourse < backup.sql
  • Start the Redis server and migrate the database:

    $ sudo /opt/bitnami/ start redis
    $ cd /opt/bitnami/apps/discourse/htdocs
    $ bin/rake db:migrate RAILS_ENV=production
  • Restore the uploaded files in the new server:

    $ tar -xzvf uploads.tar.gz -C /
  • Restart all servers:

    $ sudo /opt/bitnami/ start

Keeping in sync with the Discourse repository at GitHub

IMPORTANT: This procedure is supported since the Bitnami Discourse Stack v0.8.5-0.

NOTE: This is an advanced feature that should be used only by someone that knows the application and what is happening at every step of the process described below. If not, there is a new Discourse version available every week and the standard process to upgrade the whole stack can be followed.

Since Discourse changes very fast, the Bitnami Discourse Stack includes the .git files necessary to stay in sync with the repository.

As some configuration parameters are adjusted during the installation, there may be some differences between the installed version and the repository even if the installer was built recently. Follow these steps:

  • Change to the Discourse application directory:

    $ cd /opt/bitnami/apps/discourse/htdocs
  • Stop the Apache and Discourse services:

    $ sudo /opt/bitnami/ stop apache
    $ sudo /opt/bitnami/ stop discourse_sidekiq
  • Stop and disable the Clockwork service if your current Discourse version uses it. This step is not required since v0.9.6.1.

    $ sudo /opt/bitnami/ stop discourse_clockwork
    $ sudo mv /opt/bitnami/apps/discourse/scripts/ /opt/bitnami/apps/discourse/scripts/
  • Edit the file /opt/bitnami/scripts/ and comment the line:

    . /opt/bitnami/scripts/
  • Edit the file /opt/bitnami/ruby/.bundler/config and comment the line:

    BUNDLE_BUILD__NOKOGIRI: --with-iconv-dir=/opt/bitnami/common
  • Change to the Discourse application directory:

    $ cd /opt/bitnami/apps/discourse/htdocs
  • Checkout the master branch and pull the latest version. You will need to checkout the Gemfile and Gemfile.lock files to overwrite Bitnami’s changes to support offline installations. Note that you will need to configure Git as described in the Troubleshooting section to stash the changes if this is the first time you’re using it, and replace the LATEST-VERSION placeholder with the latest version number.

    $ git checkout Gemfile*
    $ git checkout bin
    $ git stash
    $ git fetch
    $ git checkout tags/vLATEST-VERSION
    $ git stash apply

NOTE: You may need to remove raindrops, unicorn and kgio gems from the Gemfile.lock file.

  • View the Gemfile.lock file to see the version of Bundler in use.
  • Install and configure that version of Bundler, replacing the BUNDLER-VERSION placeholder with the version number:

    $ gem install bundler -v BUNDLER-VERSION
    $ bundle config default BUNDLER-VERSION

    For example:

    $ gem install bundler -v 2.1.1
    $ bundle config default 2.1.1
  • Execute the following command:

    $ sudo bundle install --without development test sqlite --binstubs --deployment
  • Apply any new database migrations:

    $ sudo /opt/bitnami/ruby/bin/ruby bin/rake db:migrate RAILS_ENV=production
  • Recompile the application assets (it may take a few minutes):

    $ sudo chmod 666 log/production.log
    $ sudo /opt/bitnami/ruby/bin/ruby bin/rake assets:precompile RAILS_ENV=production
  • Remove the Discourse cache:

    $ sudo rm -rf tmp/cache
  • Restart Apache and Discourse servers:

    $ sudo /opt/bitnami/ start


  • If you run git and you get this output:

    Please tell me who you are.

    Run the commands below, replacing the placeholders with your name and email address:

    $ git config --global ""
    $ git config --global "Your Name"
  • If you see the following error:

    rake aborted!
    cannot load such file -- rb-inotify

    Check that you are running the command using the rake command in the Discourse directory and that the command is running in production mode:

    $ export RAILS_ENV=production
    $ cd /opt/bitnami/apps/discourse/htdocs
    $ bin/rake bundle install
  • If there is a merge conflict, it should be fixed manually. You will see an error like this:

    $ git stash apply
    Auto-merging app/assets/javascripts/discourse/routes/discourse_location.js
    CONFLICT (content): Merge conflict in app/assets/javascripts/discourse/routes/discourse_location.js
    Auto-merging app/assets/javascripts/discourse.js

    To resolve this, the files listed must be edited. There are two options:

    • Keep local changes. For each conflicting file:

      • Remove everything from <<<<<<< Updated upstream to ======= and the line >>>>>>> Stashed changes. Then, run the following command:

        $ git add FILENAME
      • Check everything. Output of this command should be as shown:

        $ git status
        Already up-to-date.
      • Unstage changes automatically set to be committed.

        $ git reset HEAD
    • Discard local changes. For each conflicting file:

      • Remove everything from ======= to >>>>>>> Stashed changes and the line <<<<<<< Updated upstream. Then, run the following command:

        $ git add FILENAME
      • Check everything. Output of this command should be as shown:

        $ git status
        Already up-to-date.
      • Unstage changes automatically set to be committed.

        $ git reset HEAD
  • On Linux 32-bit instances, you may have problems with the gem libv8- because there is no precompiled version of this gem for this platform. An easy workaround would be to edit the Gemfile.lock file and replacing libv8 ( with libv8 (

Last modification April 8, 2020