Metabase

Prerequisites

The package currently supports 2 connectors:

Postgres

The data is extracted by running SQL queries on the Postgres Database used by your metabase instance:

  • Directly on your Metabase DB

  • On a replica or views with similar structure

You will need postgres credentials with read access on Metabase tables (or views with similar columns)

Metabase API

The data is extracted by calling the Metabase API.

Prerequisites:

  • Metabase credentials with role superuser

Run extraction script

Once the package has been installed, you should be able to run the following command in your terminal:

castor-extract-metabase-db [arguments]

# or, if you use the API connector:
castor-extract-metabase-api [arguments]

The script will run and display logs as following:

INFO - Getting session_id: {'id': '****'}
INFO - Fetching USER (15 results)
INFO - Wrote output file: /tmp/catalog/1649081473-user.json
INFO - Fetching COLLECTION (41 results)

...

INFO - Wrote output file: /tmp/catalog/1649081473-dashboard_cards.json
INFO - Wrote output file: /tmp/catalog/1649081473-summary.json

Credentials

You can sign-in using one of the following methods:

  • with Postgres connector

    • -H, --host: Host name where the server is running

    • -P, --port: TCP/IP port number

    • -d, --database: Database name

    • -s, --schema: Schema name where the views or tables are located

    • -u, --user: User

    • -p, --password: Password

    • -o, --output: Directory to write to

  • with API connector

    • -b, --base-url: Metabase base url, such http://company.cloud.metabase.com

    • -u, --user: Metabase user

    • -p, --password: Metabase password

Other arguments

  • -o, --output: target folder to store the extracted files

You can also get help with argument --help

Use ENV variables

If you don't want to specify arguments every time, you can set the following ENV in your .bashrc:

# with DB connector #
CASTOR_METABASE_DB_HOST
CASTOR_METABASE_DB_PORT
CASTOR_METABASE_DB_DATABASE
CASTOR_METABASE_DB_SCHEMA
CASTOR_METABASE_DB_USERNAME
CASTOR_METABASE_DB_PASSWORD

# with API connector #

CASTOR_METABASE_API_BASE_URL
CASTOR_METABASE_API_USERNAME
CASTOR_METABASE_API_PASSWORD

# optional, valid with both connectors #

CASTOR_METABASE_ENCRYPTION_SECRET_KEY

CASTOR_OUTPUT_DIRECTORY

Then the script can be executed without any arguments:

castor-extract-metabase-db

It can also be executed with partial arguments (the script looks in your ENV as a fallback):

castor-extract-metabase-db --output /tmp/catalog

Last updated

Was this helpful?