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.
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.
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:
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.
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:
We will start with a stack which includes the following main components and versions:
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:
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.|
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
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.|
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.|
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.|
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 -
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:
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
Update the variables REDASH_VERSION and INSTALLDIR with the appropriate values.
Stack installers used in this blog post: