Upgrading your Bitnami Redash stack

Juan Ariza Toledano

Juan Ariza Toledano


Software engineer @bitnami


Share this article

Redash is an open source application that allows you to quickly access billions of records in the most popular databases. With the resulting data, you can create advanced visualizations and dashboards, so you can analyze all your data with ease.

Redash was added to the Bitnami Application Catalog in April 2016 and we have been offering installers, virtual machines, and cloud images since then.

Bitnami Redash Logo

In this blog post, we will explore in detail the process you need to follow to safely upgrade an old Bitnami Redash stack to the latest version, which includes new features and fixes several security bugs.

My Bitnami stack has not been upgraded for more than a year, what can I do?

It's quite common to find users with this kind of question on the Bitnami community forum. At Bitnami, we advice you to upgrade your stacks for two key reasons:

  • Strengthen your security: ensure every component included in the stack is not affected by any security issue.
  • Enjoy the latest application features.

Bitnami tracks the release of each stack's component and updates the stack shortly after they are released. Therefore, users can simply migrate their data to the latest stack version whenever we publish it. You can subscribe to application releases by visiting the Application Catalog and clicking on the "Follow" button on the individual app page.

Redash Site Status

It's very important to upgrade your applications regularly. It helps you to avoid conflicts in the application code and the database schemas, especially when a new major version is released. Developers often try to avoid these conflicts by migration, but that's not always effective, particulary if you want to migrate two distant versions. It can become even more complex when two stacks have different versions of the database, the web server, or the runtime.

The following instructions are for upgrading a Redash stack - and they’re very similar for upgrading any Bitnami application. This is a summary of the steps you will need to follow:

  1. Download the next consecutive version of the stack installer.
  2. Create a backup of your stack.
  3. Create a backup of your database and any other data your application may have.
  4. Run the installer you downloaded in step 1.
  5. Import the database backup and the application data on the stack installed in the previous step.
  6. Run the application migration scripts.
  7. Check that everything works as expected on the UI and there are no errors in the log files.
  8. Repeat the whole process until you have your application upgraded to the desired version

Upgrading Redash from 0.11.1 to 3.0.0

We will start with a stack which includes the following main components and versions:

Redash Upgrade

  • Redash 0.11.1.2095-1
  • Apache 2.4.23
  • OpenSSL 1.0.2j
  • PostgreSQL 9.5.4
  • Python 2.7.12
  • Redis 3.2.3

During the migration process we will use the intermediary versions: 0.12.0, 1.0.3, 2.0.0 and 2.0.1. Once it's completed, the stack will include the following main components and versions:

  • Redash 3.0.0
  • Apache 2.4.29
  • OpenSSL 1.0.2n
  • PostgreSQL 10.1
  • Python 2.7.14
  • Redis 3.2.9

Assumptions

  • The Bitnami Redash 0.11.1.2095-1 stack is already installed at the default directory /opt/bitnami/ with all the services up and running.
  • There is (at least) 2GB of free disk space.
  • You have basic command-line skills.

Migration steps

Download the next consecutive version of the stack installer

Example: to migrate from 0.11.1 to 0.12.0, run the command below to download the 0.12.0 stack installer:

$ REDASH_VERSION=0.12.0.2449-1 && \
wget https://downloads.bitnami.com/files/stacks/redash/$REDASH_VERSION/bitnami-redash-$REDASH_VERSION-linux-x64-installer.run
NOTE: You can find the links to download each stack version for installers in the Useful links section.

Create a backup of your stack.

Bitnami stacks are self-contained, so you can simply back up the whole installation directory:

$ INSTALLDIR=/opt/bitnami && sudo tar cfz redash-backup.tar.gz $INSTALLDIR

Create a backup of your database

Redash stores all the information (dashboards, queries, users, etc.) in the PostgreSQL database. To back up the database, use the command below:

$ INSTALLDIR=/opt/bitnami && \
PGPASSWORD=@@POSTGRES_PASS@@ $INSTALLDIR/postgresql/bin/pg_dump -U postgres bitnami_redash > database-backup.sql
NOTE: You need to substitute the placeholder @@POSTGRES_PASS@@ with your database's actual password.

Run the installer you downloaded in step 1

First, stop services running on the existing stack:

$ INSTALLDIR=/opt/bitnami && sudo $INSTALLDIR/ctlscript.sh stop
$ REDASH_VERSION=0.12.0.2449-1 && \
chmod +x bitnami-redash-$REDASH_VERSION-linux-x64-installer.run \
./bitnami-redash-$REDASH_VERSION-linux-x64-installer.run
NOTE: Select the default directory when you are prompted to choose an installation directory.

Import the database backup on the stack installed in the previous step

Replace the database created during the stack installation, as described below:

$ REDASH_VERSION=0.12.0.2449-1 && INSTALLDIR=/opt/redash-$REDASH_VERSION && \
PGPASSWORD=@@POSTGRES_PASS@@ $INSTALLDIR/postgresql/bin/dropdb -U postgres bitnami_redash && \
PGPASSWORD=@@POSTGRES_PASS@@ $INSTALLDIR/postgresql/bin/createdb -U postgres bitnami_redash && \
PGPASSWORD=@@POSTGRES_PASS@@ $INSTALLDIR/postgresql/bin/psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE bitnami_redash TO bn_redash;" && \
PGPASSWORD=@@POSTGRES_PASS@@ $INSTALLDIR/postgresql/bin/psql -U postgres -c "ALTER DATABASE bitnami_redash OWNER TO bn_redash;" && \
PGPASSWORD=@@POSTGRES_PASS@@ $INSTALLDIR/postgresql/bin/psql -U postgres bitnami_redash < database-backup.sql
NOTE: You need to substitute the placeholder @@POSTGRES_PASS@@ with the password you chose during the stack installation.

Run the corresponding migration scripts

The migration method will vary, depending on the version you are upgrading to.

Migrating to 0.x.x:

$ REDASH_VERSION=0.12.0.2449-1 && INSTALLDIR=/opt/redash-$REDASH_VERSION && \
cd $INSTALLDIR/apps/redash/htdocs && \
. $INSTALLDIR/scripts/setenv.sh && \
. $INSTALLDIR/apps/redash/htdocs/venv/bin/activate && \
for f in $INSTALLDIR/apps/redash/htdocs/migrations/*; do BITNAMI_ROOT=$INSTALLDIR $INSTALLDIR/apps/redash/htdocs/bin/run python "$f"; done && \
deactivate && cd -
NOTE: You might encounter some warnings during this step, but please ignore them.

Migrating to 1.x.x and higher:

$ REDASH_VERSION=1.0.3-1 && INSTALLDIR=/opt/redash-$REDASH_VERSION && \
cd $INSTALLDIR/apps/redash/htdocs && \
. $INSTALLDIR/scripts/setenv.sh && \
. $INSTALLDIR/apps/redash/htdocs/venv/bin/activate && \
BITNAMI_ROOT=$INSTALLDIR $INSTALLDIR/apps/redash/htdocs/bin/run $INSTALLDIR/apps/redash/htdocs/manage.py db upgrade
deactivate && cd -

Check that everything works as expected on the UI, and there are no errors in the log files

You've finished the migration between two consecutive versions, so now it's time to log in to the server and check everything is working as expected in the new version.

Visit the Redash System status page:

Redash Site Status

Check the redash/apps/redash/logs/ file to make sure that there aren't any errors. Once you are happy with the result, you can remove the previous stack:

$ PREVIOUS_STACK=/opt/bitnami/ && sudo rm -rf $PREVIOUS_STACK

Repeat the whole process as often as necessary, until your application is upgraded to the desired version

Update the variables REDASH_VERSION and INSTALLDIR with the appropriate values.


Stack installers used in this blog post: