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 uses port 80 to serve requests to the Prometheus client, so the port isn’t available for Nginx. To serve requests to Redash, Apache proxies requests on port 80 to port 9090.)
  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 and container startup commands (to be run after upgrade).

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

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-redash.sh file in this repository, setting the COOKIE_SECRET and SECRET_KEY variables to the values copied above.

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

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

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

    bash setup-redash.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.