Metabase H2 to PostgreSQL migration

How to move a Metabase application database from embedded H2 to PostgreSQL or MySQL with load-from-h2, what must match, and how to verify the switch.

On this page

Why Metabase H2 to PostgreSQL migration is a one-way step worth planning

The move from the embedded H2 application database to production storage is a one-time load-from-h2 run, and it must be executed with the same Metabase version that last wrote the H2 file. Metabase ships H2 for demos and recommends PostgreSQL for production, with MySQL 8.4.0 or MariaDB 10.6.0 and later (using utf8mb4) also supported. Once the data is loaded, the H2 file is no longer the source of truth, so treat the switch as a cutover you can only partly reverse. Before you start, confirm which Metabase version last touched the H2 file, since a mismatch is the most common reason the load fails or is run with the wrong binary.

The step looks simple because it is a single command, but the saved state is what makes it risky. The H2 file holds saved questions, dashboards, collections, users, groups and permission settings, which is everything your analysts have built. Stop the running instance so the file is not in use, copy the H2 file to a separate location, and keep it until you have verified the migrated instance end to end. Removing or overwriting the original file early leaves you with no fallback if the load or the new database configuration goes wrong.

Plan for the one-way nature explicitly: agree a window with the business, confirm who can sign off on the cutover, and record the Metabase version, the H2 file location and the target database details in your change record. Then check that the migrated instance shows the expected collections, permissions and data source connections before users return. The migrating from H2 documentation sets out the exact command and prerequisites, and you should confirm them against the version you are running.

The H2 file only moves when the matching JAR runs the load

The flow starts with the existing H2 application database file and the Metabase JAR that last updated it. That exact version must run the one-time load-from-h2 command, which copies the data into a new PostgreSQL or MySQL application database. Only after the load completes do you point Metabase at the new database, then check that users, questions, dashboards and connections are intact. Version match is a required gate: if the JAR differs from the version that last wrote the H2 file, stop and resolve it before loading.

The version gate and one-time load that move H2 data into a new application database.

Choosing PostgreSQL or MySQL as the target application database

PostgreSQL is the option Metabase recommends for production application databases, so it is the default most teams should evaluate first. The application database holds Metabase's users, permissions, saved questions, dashboards, and settings, so the database itself becomes a system your team has to run, patch, back up, and restore inside your own infrastructure.

  • Operations skills: Choose PostgreSQL if your database team already runs it for other internal applications, since upgrades, vacuum maintenance, and connection limits will then follow familiar procedures.
  • Backup tooling: Confirm that your existing backup product or managed snapshot process can capture the application database on a schedule and that a restore has been tested into a separate instance.
  • Hosting: Decide whether it runs on a managed service in your cloud account, a database platform in your data center, or a server you administer directly, and confirm that the network path from Metabase nodes is limited to what is needed.
  • Credentials: Create a dedicated database role for Metabase rather than reusing an administrative account, and keep its privileges limited to the application database.
  • Version coverage: Check the PostgreSQL version against the Metabase version you plan to run in the official configuration documentation before the load begins.

Before committing, ask your database team to confirm the supported PostgreSQL version and backup method in writing.

Step-by-step load-from-h2 sequence and the check that closes each step

This sequence moves a Metabase application database from the embedded H2 file to PostgreSQL or MySQL with the one-time load-from-h2 command, and each step ends with a check that tells you it is safe to continue.

  1. Confirm the running and H2 file versions

    The team member who owns the Metabase host records the version of the running JAR and the version that last updated the H2 file. Load-from-h2 must be run with the Metabase version that last wrote to that file, so a mismatch is the first thing to resolve. Check the version string in the Metabase admin area and the JAR you have on hand, and confirm they match before going further. Done means you have written down one version and the JAR file you will use for the load.

  2. Stop writes and schedule a window

    Ask the Metabase administrator to tell users that the instance will be unavailable and to stop the application so no new questions, dashboards, users or settings change the H2 file during the copy. Confirm with the business owner how long the window needs to be, since the duration depends on the size of your application database and your environment, and ask your team to test it beforehand. Done means the application is stopped and no process still holds the H2 file open.

  3. Back up the H2 file and any existing database

    Copy the H2 database file to a location outside the Metabase host, and if an application database already exists (for example, a previous PostgreSQL instance), take a dump of it as well. Keep the backups until the migrated instance has passed its checks and a rollback path is no longer needed. Done means you can restore both backups to a test location and open them, which you should confirm before you start the load.

  4. Provision an empty target database

    Create an empty PostgreSQL database, or an empty MySQL database if you use MySQL, with a dedicated account that owns it. For MySQL, use utf8mb4 as the character set, as the Metabase application database documentation requires. Confirm that the database has no existing Metabase tables, since the load should go into a clean target. Done means you can connect with the account from the Metabase host and the database is empty.

  5. Run load-from-h2 with the matching JAR

    From the host, run the load-from-h2 command using the matching Metabase JAR and the target connection details, following the migrating from H2 documentation for the exact syntax. The command is one-time, so run it only once against the empty target. Watch the output for errors and note the final message. Done means the command completes without errors and the row counts or completion message in the output match what you expect for your instance.

  6. Point the application database configuration at the new database

    Update the environment variables or configuration that tell Metabase where its application database lives, following the configuring the application database documentation, so the new PostgreSQL or MySQL target is used instead of the H2 file. Keep the H2 file in place and do not delete it. Start Metabase and watch the log until the startup completes. Done means the logs show Metabase connected to the new application database and it starts without migration errors.

  7. Verify users, content and permissions

    Sign in as an administrator and check that users, groups, collections, saved questions, dashboards, database connections and permission settings all appear as they did before the window. Run several saved questions and one dashboard against the data source to confirm the queries still work. Ask a non-admin user to sign in and confirm their access matches expectations. Done means the spot checks match the pre-migration record and you have signed off the result in writing before you reopen the instance to users.

  8. Keep the rollback path until checks pass

    Leave the H2 backup, the pre-migration dump and the H2 file unchanged until the verification step is complete and the team has signed off. Record the Metabase version, the target database type and the backup locations in your runbook so an administrator can find them later. Done means the rollback artifacts are stored, labeled and linked from the runbook, and the team agrees on when they can be removed.

What goes wrong during the switch and how to catch it

Most failed H2 to PostgreSQL moves fail quietly rather than loudly: the load completes, the server starts, and the damage only shows up later. The cards below cover the failure points that recur in this migration, each with the symptom to look for, the cause behind it and the guard to put in place before go-live.

Version mismatch between JAR and H2 file

The symptom is a load that fails or a Metabase that will not start cleanly after the move. The cause is running load-from-h2 with a Metabase JAR that is not the same version that last updated the H2 file. The guard is to read the version recorded by the running instance before the migration, keep that exact JAR available, and run the load with it. Confirm the version in your own environment before you stop the old server.

Migration docs

Loading into a non-empty target

The symptom is a load that reports conflicts, or a target database that mixes old and new application data. The cause is pointing the load at a PostgreSQL or MySQL database that already holds Metabase tables from a test start or an earlier attempt. The guard is to use a freshly created, empty application database for the target, confirm it holds no Metabase schema, and record the target name in the change ticket so a rerun cannot write into the wrong database.

Character set problems on MySQL or MariaDB

The symptom is text in saved questions, dashboard names or descriptions that arrives garbled or truncated after the switch. The cause is creating the MySQL or MariaDB application database without utf8mb4, which Metabase requires for its application database. The guard is to create the schema with utf8mb4 before the load, then compare a sample of non-ASCII titles and descriptions in the source and target. Confirm the minimum MySQL 8.4.0 or MariaDB 10.6.0 version for your deployment before you choose the engine.

Application database docs

Stale H2 backup used for rollback

The symptom is a rollback that restores a file missing the most recent questions, users or dashboard changes. The cause is keeping a backup taken days before the cutover, or copying the H2 file while the server still writes to it. The guard is to stop Metabase, copy the H2 database file and its companion files together, and label that copy with the cutover time. Keep the old server stopped but intact until the new instance passes its checks.

Users or saved questions missing after the switch

The symptom is that users cannot sign in, or that collections, saved questions or dashboards appear empty. The cause is usually an incomplete load, a load run against the wrong target, or a new instance started with a fresh application database by mistake. The guard is to compare user, collection, card and dashboard counts between the H2 source and the PostgreSQL target, then sign in as a known admin and open a sample of saved questions before users are told the system is live.

What drives the effort and downtime of the move

This table lists the factors that change how long the H2 to PostgreSQL move takes and how long Metabase is unavailable. Read each row as a lever: the driver on the left is what grows the work, and the right column shows how to keep it under control before the cutover window opens.

DriverWhy it changes effort or downtimeHow to keep it down
Size of the H2 fileThe load-from-h2 command copies the whole application database, so a larger H2 file generally means a longer copy and a longer window with Metabase stopped.Check the file size first, remove obsolete data where your governance allows, and rehearse the load on a copy to measure the real run time.
Saved questions and dashboardsMany questions, dashboards and cards add rows and dependencies that must be checked after the switch, so validation takes longer even when the copy is quick.Inventory the most-used content, agree a short list of critical dashboards to test, and archive unused items before the move.
Number of users and groupsEvery user, group and permission mapping must load and log in correctly, and group-based access problems often surface only after go-live.Export the current user and group list, confirm who needs access, and test one account from each permission group after the switch.
Single node or several nodesA cluster must be reduced to a single node for the migration, and each additional node adds coordination, shutdown and restart steps.Confirm the topology in advance, plan the node shutdown order, and record the target configuration so nodes can be restored cleanly.
Number of environmentsDev, staging and production each need the same procedure, so mistakes or surprises found in one environment repeat in the others.Run the full procedure in a non-production copy first, document each run, and reuse the same runbook for production.
Custom configuration and embeddingCustom settings, SSO, embedded dashboards and allowed origins can break silently after a database change and need retesting.Record environment variables and admin settings beforehand, and include embedded pages and SSO logins in the test list.
Database host and backup storage accessCreating the target PostgreSQL or MySQL database, granting credentials and storing the H2 backup all depend on access that may need change requests.Request access to the target database host and backup location early, confirm credentials and network paths, and check that a backup can be restored.

How the switch differs on a single node, a cluster and an air-gapped network

A single node is the simplest case: one Metabase JAR, one application database connection, and one place where the H2 file lives. The migration is a bounded maintenance task. You stop Metabase, run the one-time load-from-h2 command against the target PostgreSQL or MySQL database using the same Metabase version that last updated the H2 file, and then point the configuration at the new database and start the JAR again. The main planning question is how long the restart window needs to be, which depends on the size of your H2 file and your environment, so confirm that with a test run on a copy.

  • Version match first: confirm the exact Metabase version that last wrote the H2 file before you run the load command, because the docs require the same version.
  • One stop, one start: the service is down from the moment you stop the JAR until the new configuration is confirmed, so schedule that window with users informed.
  • Keep the H2 file: leave the original H2 file in place and untouched until the new database has been checked.
  • Configuration change: update the application database settings to the new host, database name and credentials, then restart.
  • Rollback path: if the switch fails, restore the previous configuration and the H2 file, then start the same version again.

Before closing the window, check that users can sign in, that saved questions and dashboards load, and that scheduled jobs and data source connections still work.

Protecting credentials, backups and the migrated data

The H2 file, the migration host and the new PostgreSQL connection all hold the same business data and account records, so each needs the same care as production. The four cards below cover the controls to set before the load-from-h2 command runs and the checks to make before users return.

Least-privilege database credentials

Create a dedicated PostgreSQL role for the Metabase application database and grant it only the rights it needs on its own database, not superuser or access to other schemas. Metabase keeps its users, questions, dashboards and settings there, so a broad role would expose all of them. Confirm the role's exact grants against the current application database documentation before go-live, and keep the password out of shell history and plain-text config files.

Application database docs

Handling the H2 backup

The H2 file contains user accounts, password hashes, session data and saved content, so treat the copy as sensitive. Store it encrypted or on restricted storage, record who holds it, and set a retention date after the migration is verified rather than keeping it indefinitely. Delete temporary copies made during testing, and confirm your own backup policy covers the file for the same period as the production database.

Restricting the migration host and JAR

The migration runs from a host that can read the H2 file and write to PostgreSQL, so limit shell access to the people running the migration and remove access once it closes. Use the same Metabase JAR version that last updated the H2 file, and keep copies of that JAR in a controlled location with checksums recorded. Log who ran the command and when, because the process touches every application record.

Migration from H2 docs

Verifying TLS and encryption settings

Confirm that the connection from Metabase to the new database uses TLS and that the database server accepts only encrypted client connections for this role. Check the certificate chain that Metabase trusts and the encryption settings your PostgreSQL or MySQL version supports, and confirm the exact configuration keys with the vendor documentation for your version. Test the connection after setup and confirm that unencrypted connections are refused.

How to confirm the migrated Metabase works and fails safely

Treat the switch as complete only after a side-by-side count check of the application database. Before the load-from-h2 run, record the number of users, collections, saved questions and dashboards from the H2 instance, using the admin interface or the REST API. After the move, repeat the same counts against the PostgreSQL instance and investigate any difference before users return. Then sign in as an admin and as a standard user with restricted collection access, and confirm that each account sees the same collections and content it saw before. Keep the counts and the test accounts in your change record so the comparison can be repeated after later changes.

Next, exercise the parts of Metabase that depend on the connected data sources and background jobs. Open a representative set of saved questions and dashboards that query each production database, confirm they return results, and check that the data source connection settings carried over correctly. Review scheduled subscriptions and alerts, since these run from the application database and should be confirmed to fire on schedule. Check row and column permissions only if your plan includes them, because the open source edition does not offer those controls. Ask your Metabase contact to confirm which of these checks apply to your edition and configuration.

Plan the rollback before you start. The recommended path is to restore the pre-switch backup of the H2 application database and point Metabase back at it, so that the backup must be verified as restorable before the switch. Test the restore on a separate host and confirm that Metabase starts against it. The rollback options described in the upgrading Metabase documentation (restoring a backup or running the migrate down command) apply to later version upgrades, not to this one-time move from H2, so do not assume them here.

What to back up, monitor and document after go-live

This table lists what the team should protect, watch and record once Metabase runs on PostgreSQL instead of H2. Each row ties a control to the supported version windows, so the team can plan the next upgrade with a verified backup and a current runbook. Read it as a go-live checklist: the owner column shows who signs off each item.

ItemWhat to doOwner and timing
Application database backup before the next upgradeTake a fresh backup of the new PostgreSQL application database before any upgrade, since rollback is done by restoring that backup or running migrate down with the newer JARDatabase administrator, before every upgrade
Database and application log monitoringWatch PostgreSQL availability, connection counts and storage growth, and review Metabase application logs for migration or database errors after the switchPlatform engineering, continuous with alert review
Recorded Metabase versionRecord the exact Metabase version and JAR build in the runbook, since load-from-h2 had to match the version that last updated the H2 filePlatform owner, updated at each upgrade
Version support windowTrack the end-of-life date for the running release, noting LTS versions are supported for 14 months and non-LTS versions usually for about 2 monthsPlatform owner, reviewed against the version support page
Target database settingsDocument host, database name, encoding, character set and the least-privilege account used by Metabase, with each setting's ownerDatabase administrator and security team, kept in the runbook
Retired H2 file retentionKeep the old H2 file read-only for an agreed period after cutover, then archive or delete it under the data retention policyPlatform owner and compliance lead, decided before cutover
Post-switch checks logRecord the results of the post-switch checks, such as login, saved questions and dashboard queries, with the date and tester nameQA or analytics lead, filed at go-live

Questions teams ask before moving off H2

How much does moving Metabase off H2 cost?

The software move itself carries no license fee, because the load-from-h2 command is part of Metabase and the open source edition is licensed under the AGPL. Cost comes from labor and infrastructure: the time to plan the window, prepare a PostgreSQL or MySQL application database, run the move and verify the result, plus the database server you run it on. Scope drivers include how many Metabase instances or environments need the move, how large the H2 file is, whether you use SSO or other paid features that need configuring afterward, and how much testing your team requires before cutover. Ask any partner for a fixed-scope quote that lists each environment, the database platform, the backup approach, the verification steps and who performs each one.

How long does the migration take, and does it need downtime?

Yes, plan for downtime. Metabase should be stopped while the H2 file is copied to the new application database, because the install must not change during the move. The duration depends on the size of the H2 file, the speed of the target database, the number of environments and how many checks your team runs before users return. Ask for a timeline that separates the rehearsal on a copy from the production window, since a rehearsal shows the real duration and exposes version or permission problems before users are affected. Confirm the window with the people who own dashboards that refresh on schedule.

Can our internal team run the migration without outside help?

Often yes, if the team already runs Metabase and PostgreSQL and can follow the official procedure in a test environment first. The work requires someone who can create the target database and its role, run the Metabase JAR with the correct version and configuration, and confirm that logins, collections, questions and dashboards look right afterward. Teams with a single operator, no staging copy, or no tested rollback plan usually take more risk on the production night. An outside partner is useful when the team wants a fixed-scope rehearsal, a second pair of eyes on the checks, or help with the surrounding work such as backups and monitoring.

What does the migration need from our team?

The work needs four things from your side. First, database access: an administrator who can create the target PostgreSQL or MySQL database and a dedicated least-privilege account for Metabase. Second, backup storage: space and a tested location for a copy of the H2 file and a dump of the target database before and after the move. Third, a maintenance window agreed with the business owners who depend on Metabase. Fourth, the exact Metabase version currently running, since the load-from-h2 command must be run with the same version that last updated the H2 file. Confirm the version from the admin settings or the running JAR before scheduling anything.

Does moving off H2 change our licensing or edition needs?

No. Moving the application database does not change which Metabase edition you run or what it costs to run it. Features such as SSO, row and column level permissions, and usage analytics and auditing depend on the plan you hold, not on the database behind it. Check the pricing page and the plan you already have before the move, and confirm that any paid features you rely on are active in the migrated install. If you plan to add a paid plan later, that decision is separate from this migration and should be scoped on its own.

What should we do if load-from-h2 fails?

Stop, do not retry against the production target, and keep the original H2 file untouched. First, confirm the Metabase version matches the one that last updated the H2 file, because a mismatch is a common cause. Next, check the connection settings, database permissions and character set on the target, since MySQL and MariaDB need utf8mb4. Read the error output and the Metabase logs before changing anything. If the target is partly populated, restore it from your pre-move backup rather than patching it by hand. Keep a written rollback path so the team knows the exact restore steps before the window opens.

Can we upgrade Metabase right after the migration?

Wait until the migrated install passes your post-move checks before upgrading. Metabase runs application database migrations automatically during an upgrade, so take a fresh backup of the new PostgreSQL or MySQL database first. The upgrade documentation recommends reducing a cluster to a single node for major upgrades because of a migration lock, and upgrading release by release if your version is older than 40. Confirm the target version against the version support page, which lists long-term support releases and end-of-life dates, and keep the pre-upgrade backup as your rollback point.

How DeployOpen scopes, runs and hands over an H2 to PostgreSQL move

DeployOpen plans and carries out the move of a self-hosted Metabase application database from the embedded H2 file to PostgreSQL inside your own infrastructure. The work is agreed as a fixed scope with written deliverables, then built, tested and documented so your team can run the result.

How we scope

  • Inventory the current Metabase version, the H2 file location and the exact JAR used to last update it.
  • Agree the target PostgreSQL or MySQL instance, network path, credentials and backup location in writing.
  • Confirm the maintenance window, rollback plan and who signs off the cutover before any work starts.

How we build

  • Stage a copy of the H2 file and run load-from-h2 with the matching Metabase version in a non-production environment.
  • Compare users, collections, questions, dashboards, permissions and data source connections before and after the load.
  • Switch the production application database setting only after the staging run completes and the checks pass.

How we hand over

  • Deliver a runbook covering backups taken, the commands used, the version pinned and the rollback steps.
  • Document the post-switch checks, the owners of each check and the results recorded during the cutover.
  • Walk your platform and security teams through the configuration, including database credential handling.

How we support

  • Engagements are fixed-scope, so changes after go-live are scoped and quoted separately in writing.
  • Ongoing support, version upgrades and continuous testing are available as a retainer after handover.
  • Ask us to confirm the supported Metabase version path, since LTS and non-LTS windows affect the next upgrade.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.