Skip to content
Snippets Groups Projects
Commit c5291d21 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

adding section to operations guide detailing how to migrate the H2 database to MySQL or Postgres.

parent 88bacdc2
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
> [How to install Metabase](#installing-and-running-metabase)
> [Tips for troubleshooting various issues](#troubleshooting-common-problems)
> [Configuring the application database](#configuring-the-metabase-application-database)
> [Migrating from using the H2 database to MySQL or Postgres](#migrating-from-using-the-h2-database-to-mysql-or-postgres)
> [Running database migrations manually](#running-metabase-database-migrations-manually)
> [Backing up Metabase Application Data](#backing-up-metabase-application-data)
> [Customizing the Metabase Jetty Webserver](#customizing-the-metabase-jetty-webserver)
......@@ -102,6 +103,29 @@ If you prefer to use MySQL we've got you covered. You can change the applicatio
This will tell Metabase to look for its application database using the supplied MySQL connection information.
# Migrating from using the H2 database to MySQL or Postgres
If you decide to use the default application database (H2) when you initially start using Metabase, but decide later that you'd like to switch to a more production ready database such as MySQL or Postgres we make the transition easy for you.
Metabase provides a custom migration command for upgrading H2 application database files by copying their data to a new database. Here's what you'll want to do.
1. Shutdown your Metabase instance so that it's not running. This ensures no accidental data gets written to the db while migrating.
2. Make a backup copy of your H2 application database by following the instructions in [Backing up Metabase Application Data](#backing-up-metabase-application-data). Safety first!
3. Run the Metabase data migration command using the appropriate environment variables for the target database you want to migrate to. You can find details about specifying MySQL and Postgres databases at [Configuring the application database](#configuring-the-metabase-application-database). Here's an example of migrating to Postgres.
export MB_DB_TYPE=postgres
export MB_DB_DBNAME=metabase
export MB_DB_PORT=5432
export MB_DB_USER=<username>
export MB_DB_PASS=<password>
export MB_DB_HOST=localhost
java -jar metabase.jar load-from-h2 <path-to-metabase-h2-database-file>
It is expected that you will run the command against a brand new (empty!) database and Metabase will handle all of the work of creating the database schema and migrating the data for you.
**Note:** It is required that wherever you are running this migration command can connect to the target MySQL or Postgres database. So if you are attempting to move the data to a cloud database make sure you take that into consideration.
# Running Metabase database migrations manually
When Metabase is starting up it will typically attempt to determine if any changes are required to the application database and it will execute those changes automatically. If for some reason you wanted to see what these changes are and run them manually on your database then we let you do that.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment