Redash tasks

Create a Redash server

First, create the new server, making sure to use the redash state file.

Update script

We installed Redash using its setup script. However, we made a few changes to its setup.sh file:

  1. Add a comment with a link to the version used of the setup script (to make it easier to compare against future scripts).
  2. Comment out the install_docker function call. (The docker state file installs Docker, to keep system packages under Salt’s management.)
  3. Change the nginx service’s ports to 9090:80 instead of 80:80. (Apache is used to acquire SSL certificates.)
  4. Expose the postgres service’s ports as 5432:5432 (to make it easier to load a database dump).
  5. Comment out the database creation (docker-compose run) and container startup (docker-compose up) commands (to be run after upgrade).

We also:

  1. Remove unneeded packages apt-transport-https and curl
  2. Run shellcheck salt/redash/files/setup.sh
  3. Run shfmt -d -i 4 -sr salt/redash/files/setup.sh
  4. Apply the Shell script style guide.

Before running the script, compare the setup.sh file in this repository to the latest version of the setup script:

curl -sS https://raw.githubusercontent.com/getredash/setup/master/setup.sh | diff -uw - salt/redash/files/setup.sh

Run script

  1. If migrating from an old server, get its configuration settings and database dump.

    1. Connect to the old server. For example:

      curl --silent --connect-timeout 1 redash.open-contracting.org:8255 || true
      ssh root@redash.open-contracting.org
      
    2. Copy the values of the REDASH_COOKIE_SECRET and REDASH_SECRET_KEY variables in the /opt/redash/env file on the old server:

      cat /opt/redash/env
      
    3. Dump the database. You might need to expose ports for the postgres service.

      pg_dump -h localhost -U postgres postgres -f redash.sql
      
    4. Disconnect from the old server:

      exit
      
    5. Copy the database dump to your local machine. For example:

      scp root@redash.open-contracting.org:~/redash.sql .
      
    6. Copy the database dump to the new server. For example:

      scp redash.sql root@HOSTNAME:~/
      
    7. Edit the setup.sh file in this repository, setting the COOKIE_SECRET and SECRET_KEY variables to the values copied above.

  2. Copy the setup.sh file in this repository to the new server. For example:

    scp setup.sh root@HOSTNAME:~/
    
  3. Connect to the new server. For example:

    ssh root@HOSTNAME
    
  4. Run the setup.sh file:

    bash setup.sh
    
  5. If migrating from an old server, restore the database dump and upgrade the database.

    1. Get the PostgreSQL credentials on the new server:

      grep REDASH_DATABASE_URL /opt/redash/env
      
    2. Start the postgres service:

      docker-compose up -d postgres
      
    3. Load the database dump using the PostgreSQL credentials:

      psql -h localhost -U postgres postgres -f redash.sql
      
    4. Apply database migrations (starts services as needed):

      docker-compose run --rm server manage db upgrade
      
  6. If creating a new server from scratch, create the database:

    docker-compose run --rm server create_db
    
  7. Remove the ports variable from the /opt/redash/docker-compose.yml file:

    sed -i '/postgresql/{n;N;d}' /opt/redash/docker-compose.yml
    
  8. Edit the opt/redash/env file to enable the permissions feature:

    echo 'REDASH_FEATURE_SHOW_PERMISSIONS_CONTROL=true' >> /opt/redash/env
    
  9. Edit the opt/redash/env file to configure the mail server.

  10. Restart Redash:

    docker-compose stop
    docker-compose up -d
    
  11. Test the email configuration using the Password Reset feature.

Upgrade the Redash service

To upgrade Redash without creating a new server, see the official documentation and release list.

  • If instructed, edit the docker-compose.yml file in the /opt/redash directory.
  • If missing, add the -d option to any docker-compose up commands from Redash’s documentation, to run containers in the background.

To compare the docker-compose.yml file to that in the getredash/setup repository, run:

curl -sS https://raw.githubusercontent.com/getredash/setup/master/data/docker-compose.yml | diff -u - /opt/redash/docker-compose.yml

Note

The getredash/setup repository might not be up-to-date.

Finally, check that the new version is running by accessing Redash, clicking your name, and reading the Version.

Troubleshoot

To troubleshoot docker-compose commands, add the --verbose option.