You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a docker-container based on Metabase container that automatically saves Metabase H2 database to SQL-file and creates Metabase H2 database from SQL-file.
metabase-sql-wrapper is a Docker container based on the Metabase container. It automatically saves the Metabase H2 database to an SQL file when the container stops and recreates the H2 database from the SQL file when the container starts (if the database does not already exist).
This allows to save the Metabase H2 database SQL-file to Git, versioning changes and restore the database from SQL-file.
If you like the idea click ⭐ on the repo and stay tuned.
Run container
git clone https://github.com/anki-code/metabase-sql-wrapper
cd metabase-sql-wrapper
docker-compose up
MB_DB_FILE: /data/metabase
MB_DB_INIT_SQL_FILE: /data/metabase.db.sql # (optional) used to build the DB if MB_DB_FILE doesn't exists
MB_DB_SAVE_TO_SQL_FILE: /data/metabase.db.sql # (optional) used to save SQL when container was stopped
docker-compose up runs run.xsh with xonsh shell wrapper that catches
the docker signals and environment variables and do saving or creating the Metabase DB after stopping
or before starting the container.
If MB_DB_INIT_SQL_FILE is set and MB_DB_FILE directory doesn't exists then before running Metabse
the database will be created from the SQL-file.
If MB_DB_SAVE_TO_SQL_FILE is set and the container will get stop/restart signal then the database will be saved
to SQL-file after Metabase has been stopped.
This way you can run container, save your queries to Metabase, stop the container and commit it to Git.
Cleaning the database before commit to Git
By default Metabase writes logs and history to the database. To clean this before commit to Git you can
use the metabase-db-clean.sql script:
This is a docker-container based on Metabase container that automatically saves Metabase H2 database to SQL-file and creates Metabase H2 database from SQL-file.