Moving Metabase application database from MySQL to PostgreSQL: what the work involves
A team running self-hosted Metabase on MySQL or MariaDB as its application database and wanting PostgreSQL, the platform's recommended production choice, can make the move with a documented sequence: dump the existing application database to an H2 file with dump-to-h2, then load that file into PostgreSQL with load-from-h2. The commands are short. The risk sits in the details: the H2 file must be read by the same Metabase version that last wrote it, and encryption settings must carry through correctly. Confirm both before you touch production, and run the exercise against a copy of the instance first.
The effort depends mainly on the size of the application database, how many Metabase nodes sit behind your load balancer, and whether you can keep the old instance running in parallel while you test. Ask your team to measure the database size, count the nodes and decide how much parallel running and cutover testing your change process requires before you estimate duration. The application database holds users, groups, saved questions, dashboards, collections, permissions and settings. It does not hold the data in your analytical warehouse, so the move does not copy warehouse tables, but it does carry the content your people depend on every day.
Plan for a single cutover window. Metabase needs its application database during startup and migration, and a cluster should be reduced to one node for major changes, so decide who will stop traffic, who owns the rollback and who signs off on the restored content. Keep a verified backup of the MySQL or MariaDB database as your rollback path. Also record the Metabase version, the encryption key and the environment variables your deployment uses, because the new instance must match them. Confirm the exact PostgreSQL major version you plan to run against the Metabase application database documentation, and check which PostgreSQL versions remain in support before you choose one, since support windows differ by release.
What carries over from MySQL to PostgreSQL and what needs checking
This table compares what lives in the Metabase application database, which moves with the dump-to-h2 and load-from-h2 commands, against what sits in environment variables or JVM settings and must be carried over by hand. Read the middle column as the content that moves, and the last column as the item to verify on the target before users return.
| Item | Moves in the application database | Check on the PostgreSQL target |
|---|---|---|
| Source database version | Source must be MySQL 8.4.0 or MariaDB 10.6.0 or later with utf8mb4 | Confirm the source version and character set before dumping, since older versions are outside the supported list |
| Users and groups | Yes, user accounts, group membership and group permissions are stored in the database | Sign in as an admin and as a non-admin user, then compare group membership with the source |
| Saved questions and dashboards | Yes, questions, dashboards, models and their card definitions | Open a sample of dashboards and run saved questions against the warehouse to confirm results load |
| Collections and permissions | Yes, collection tree, data permissions and collection permissions | Spot-check restricted collections with a test account from each group |
| Encrypted database connection credentials | Stored in the database, but readable only with the original encryption key | Carry the same MB_ENCRYPTION_SECRET_KEY value to the new instance or stored passwords will not decrypt |
| Connection and sync settings | Stored in the database, including sync and scan schedules and caching options | Re-check schedules and cache settings in the admin panel, because they are not visible in the dump summary |
| Email, SSO and authentication settings | Stored in the database for many settings, but some are supplied by environment variables | Confirm SMTP, SSO and LDAP settings work, and check which values come from environment variables instead |
| Site URL and TLS settings | Site URL is stored in the database, while the reverse proxy and certificates live outside it | Update the site URL and confirm links in alerts and emails point to the new host |
| JVM memory and Java options | Not stored in the database | Set heap and JVM options on the new host to match the sizing used before the move |
| Environment variables such as port, database connection and secret key | Not stored in the database | Rewrite the database connection variables for PostgreSQL and document every other variable from the source host |
Which documented commands and paths the move uses
The dump-to-h2 command reads the current application database and writes its contents into a new H2 file. It is the documented starting point for moving off MySQL or MariaDB, and it is the path that keeps the instance's encryption key meaningful after the move. Run it with the same Metabase JAR that the running instance uses, so the file reflects the schema the instance already has.
- Source database: The command reads the application database that the running instance is configured to use, so confirm the connection settings point to the MySQL or MariaDB database you intend to migrate.
- New target file: The command writes a new H2 file. If a file already exists at the target path, use the documented option to keep the existing file only when you intend to reuse it, and never overwrite one you have not identified.
- Encryption key: Keep the
MB_ENCRYPTION_SECRET_KEYvalue that the instance uses today, because encrypted values in the application database depend on it after the load. - Version match: Record the exact Metabase version used for the dump, since the load step must run with the same version that last wrote the H2 file.
- Backup: Store the original MySQL or MariaDB backup and the H2 file together so you can restore the source if the load fails.
Before moving on, confirm the H2 file exists at the path you expect, that its size is plausible for your instance, and that the key you plan to use for the new PostgreSQL target is the same one the source instance uses.
The dump-to-h2 command also has an option to dump contents unencrypted. This exists for cases where the encryption key cannot be carried into the new environment, but it changes what the file contains and who can read it. An unencrypted dump puts sensitive values such as database connection credentials and stored secrets into a file that anyone with access to it can read, so it should be a deliberate decision rather than a default.
- When it applies: Consider it only when you cannot preserve the existing encryption key for the target, and confirm that choice with your security team first.
- Sensitive content: Expect database credentials and other stored secrets in readable form, including values that Metabase uses to connect to your data sources.
- File handling: Restrict file permissions, move the file over an approved channel, delete working copies after the load and record where each copy lived.
- Key trade-off: Losing the key means encrypted values may not be recoverable after the move, so plan to re-enter database connection details and other secrets in the new instance.
- Documented behavior: Check the Metabase JAR commands page for the exact option name and any notes on the version you run.
Before using this path, confirm in writing who approved an unencrypted intermediate file and how it will be destroyed after the load.
The load-from-h2 command moves the H2 file into the new application database. Metabase documents it as a one-time operation, and it must run with the same Metabase version that last wrote the H2 file. The target PostgreSQL database is set through the application database settings, so the command writes into the database that the instance will use after the cutover.
- Version match: Run load-from-h2 with the Metabase version that last updated the H2 file, not the newest release you plan to run later.
- Target configuration: Set the application database type and connection values for PostgreSQL in the same way the instance will read them after cutover, using the documented configuration keys for the application database.
- Empty target: Confirm the PostgreSQL database is new and empty, so the load does not mix with existing Metabase tables.
- Encryption key: Start the instance with the same encryption key in the same environment used for the source, so stored values remain readable.
- Verification: After the load, sign in, check users, groups, saved questions, dashboards and database connections, and only then upgrade the version.
Before switching traffic, confirm with your Metabase version and PostgreSQL version documentation that the target major version is supported for your plan.
How the cutover runs: inventory, dump, load, parallel run and decommission
The sequence moves the Metabase application database from MySQL or MariaDB to PostgreSQL in a way that can be checked at each stage and reversed until the old database is retired.
Inventory versions, key and database state
Record the Metabase version that currently runs in production, the MySQL or MariaDB version behind it, and the character set of the application database, which must be utf8mb4. Confirm that the MB_ENCRYPTION_SECRET_KEY value is stored safely outside the running configuration, because saved database connection credentials in Metabase depend on it. Pick the target PostgreSQL major version from the releases still in support on the PostgreSQL versioning policy, so the new database does not reach end of support soon after cutover. The output is a written inventory signed off by the platform owner.
Take a verified backup of the MySQL application database
Take a full backup of the MySQL or MariaDB application database and restore it to a scratch server to confirm it is readable. Keep this backup until the new PostgreSQL instance has run in production for a period your team agrees in advance. Store a copy of the encryption key alongside it under the same access controls. The output is a restore test that completed and a documented location for the backup and key.
Run dump-to-h2 against a copy
Stop nothing on production. Point a copy of the Metabase configuration at a restored copy of the MySQL application database, then run the dump-to-h2 command from the Metabase JAR to write a new H2 file. Use an encrypted dump unless your security team has approved otherwise, since the dump contains Metabase users, connection settings and saved content. Use the same Metabase version that runs in production for this step. The output is an H2 file and a log with no errors.
Confirm the Metabase version used for load
Check that the Metabase JAR used for load-from-h2 is the same version that last wrote the H2 file, as the Metabase migration documentation requires. If the production instance was upgraded after the dump, rerun the dump with the matching version. Record the version string in the cutover log. The output is a matched pair of version and H2 file, with no mismatch left unresolved.
Load the H2 file into a new PostgreSQL database
Create an empty PostgreSQL database and a dedicated role for Metabase with rights limited to that database. Run load-from-h2 with the PostgreSQL connection details and the same encryption key used for the dump. Check the load output for errors and compare row counts for key tables such as users, collections, cards and permissions groups against the MySQL source. The output is a PostgreSQL application database with matching counts and no load errors.
Start a pilot instance and run parallel checks
Start a pilot Metabase instance on the same version that points at the new PostgreSQL database, with a separate hostname and no public traffic. Check that a sample of saved questions and dashboards return the same results as production, that collection and data permissions match for representative groups, that SSO and scheduled emails behave as expected, and that the encryption key decrypts saved database connections. Record each check and its result. The output is a signed checklist with any differences resolved or accepted.
Cut over DNS or the load balancer
Plan the cutover window with the users and owners of dashboards, and freeze content changes in production before the final dump if you plan a delta sync. Switch the DNS record or load balancer target to the instance connected to PostgreSQL, then confirm login, a query run and a scheduled job. Keep the MySQL instance and backup available and read only. The output is production traffic served from PostgreSQL with a rollback path documented.
Retain MySQL for rollback and then decommission
Keep the MySQL application database and its backup for the rollback period agreed before cutover, and keep the old Metabase configuration ready to point back if a critical fault appears. After the period ends with no rollback needed, archive the final MySQL backup according to your retention policy, remove the old database and revoke its credentials. The output is a closed cutover record, with the retained backup location and the date of decommission.
Why the Metabase version and encryption key decide whether the move works
The load-from-h2 step only works when the Metabase version matches the version that last wrote the H2 file. The intermediate file created by dump-to-h2 records the state of the application database as that exact release left it, so the team has to run the same Metabase JAR for both the dump and the load. Before dumping, confirm the running version on the source instance, then confirm that the JAR used for the dump reports the same number. If the source is on an older release, the match has to be built deliberately: upgrade the source first, and do not rely on loading into a newer or older JAR and hoping migrations reconcile the difference.
Upgrade order matters when the source is far behind. Metabase's upgrade guidance recommends upgrading release by release when the instance is on a version older than 40, rather than jumping straight to the current release. Each step runs application database migrations automatically, so the team should take a verified backup of the application database before every upgrade, not only before the first one. The upgrading Metabase guide also describes rollback by restoring that backup, which is the simplest recovery path if a step fails partway through.
Encryption is the other gate. If the source instance encrypts stored database connection details with an encryption key, the dump carries that encrypted content, and the new PostgreSQL-backed instance must be started with the same key or those credentials cannot be read. Confirm where the key is set on the source, copy it into the target's secret store, and test it before cutover. The dump-to-h2 command can write an unencrypted file instead. That is useful for debugging, but the intermediate file then holds connection secrets in clear form, so it needs the same access controls and deletion schedule as a database backup, and the team should record that choice in its change ticket.
What makes the migration larger or smaller
The effort of moving a Metabase application database from MySQL or MariaDB to PostgreSQL depends less on the database engine than on what the database holds and what depends on the instance. The six drivers below show which parts of your environment raise or lower the work, and what to measure before you schedule the move.
Size of the application database
The dump and load steps scale with how much content the application database holds, including saved questions, dashboards, collections, permissions and query history. A larger database takes longer to dump to H2 and load into PostgreSQL, and it leaves more room for error during validation. Before you plan a window, ask your Metabase administrator to measure the database and the number of saved questions and dashboards, then run a test load on a copy. Check the size of the H2 file the dump creates, since it must fit on the machine running the commands.
Migrating from H2 docsUsers, groups and SSO setup
Users, groups and their sign-in configuration live in the application database, so a larger directory means more records to verify after the load. SSO settings, group mappings and sessions also carry over, but they depend on the instance URL and identity provider callbacks, which may change during cutover. If you use SAML, OIDC, JWT or LDAP sync, record each configuration and confirm that users can sign in against the new database before you retire the old one. Plan a sign-in test with a representative set of users from each group.
Number of Metabase nodes
A single node can be dumped and switched over with one restart. A cluster must be reduced to one node for a major upgrade because of a migration lock, and the same caution applies when you move the application database, so confirm the procedure against the version you run. Each extra node also needs its configuration pointed at the new database, and any node left running against MySQL can write changes that the dump does not capture. Count the nodes, their load balancer entries and any scheduled jobs before you start.
Upgrading Metabase docsVersion gap between source and target
The load-from-h2 command must run with the same Metabase version that last wrote the H2 file. If your MySQL instance has been upgraded more recently than the JAR you use for the dump, or the reverse, the sequence fails or requires extra steps. A larger gap between the running version and the version you target also means more application database migrations to pass through. Record the exact version on the source instance, match it for the dump and load, and plan any upgrade as a separate, backed-up step.
PostgreSQL version and hosting
The version you choose sets how long the database receives support, and whether you run it yourself or use a managed service affects backups, failover and patching. Check the supported major versions on the PostgreSQL versioning policy before you choose one, and confirm that your hosting platform offers it. Self-managed PostgreSQL also needs point-in-time recovery, connection pooling and a tested restore path, which add work that a managed service may already cover. Ask your platform team who will own those tasks after cutover.
PostgreSQL versioning policyIntegrations pointing at the instance
Embeds, API clients, scripts, and reverse proxy rules that call the Metabase instance will keep working only if their URLs, API keys and session handling still match after the move. Each guest embed, public link or automation that depends on the application database contents adds a test to the validation list. Inventory every consumer before cutover, note which ones use API keys or session tokens, and schedule time to test each one against the new instance. A short list makes the cutover smaller.
How cost and duration are built from the move components
This table breaks the MySQL to PostgreSQL move into its cost components, showing who does each piece, whether it happens once or recurs, and what drives it up or down. Use it to compare an internal estimate with a partner quote and to confirm that each line is covered in writing. No price or duration is given here because none was supplied for this move, so the quote itself is the figure to request.
| Component | One-time or recurring | What drives the effort |
|---|---|---|
| Discovery of the current version and encryption setup | One-time | Confirming the exact Metabase version, the MySQL or MariaDB version, whether the instance uses encryption and how many nodes run |
| Backup and rehearsal runs | One-time, repeated per rehearsal | Database size, number of dump and load rehearsals needed, and how many verification passes the team wants before cutover |
| PostgreSQL provisioning and hardening | One-time | Chosen PostgreSQL major version, high availability design, authentication method, network placement and connection pooling |
| Load and verification | One-time | Confirming the load-from-h2 run succeeds on the same Metabase version, then checking content, users, permissions and scheduled jobs |
| Parallel run and cutover | One-time | Length of the parallel period, number of users and integrations that must be repointed, and the change window agreed with stakeholders |
| Decommission of MySQL | One-time | Retention rules for the old database, backup handling and removal of unused credentials and firewall rules |
| PostgreSQL patch and backup operations | Recurring | Patch cadence, backup retention, restore testing and whether the team or a retainer covers on-call response |
What usually goes wrong when the application database changes engines
Moving the Metabase application database from MySQL to PostgreSQL is mostly a matter of sequencing: the dump, the H2 file, the load and the cutover must agree on versions, keys and timing. The cards below cover the failure points that most often break that sequence, with a prevention for each.
Loading with a different Metabase version
The load-from-h2 command must be run with the same Metabase version that last wrote the H2 file. If the dump was produced by one JAR and the load runs with another, the migration can fail or leave the target database in an unexpected state. Record the exact version of the JAR used for dump-to-h2, and run load-from-h2 with that same JAR before any upgrade on the new PostgreSQL target.
Migrating from H2 docsLosing or mismatching the encryption key
Metabase encrypts stored database connection details and other secrets with the encryption key configured on the instance. If the new host runs with a different key, the migrated instance cannot read those secrets and warehouse connections fail. Confirm that the same MB_ENCRYPTION_SECRET_KEY value is set on the new deployment, and store it in your secrets manager before the dump starts.
Cutting over without a tested rollback path
A cutover that cannot be reversed leaves you stuck if PostgreSQL behaves differently under load. Keep the MySQL application database intact and read-only as a fallback until the new instance has run through a full business cycle. Rehearse a rollback on a copy of the environment, and confirm who makes the decision to switch back and within what window.
Stale dump while users still write
If users keep creating questions, dashboards or users in MySQL after the dump-to-h2 run, those changes are absent from the PostgreSQL instance. Stop writes by putting Metabase into maintenance or taking the old instance offline before the final dump. Then compare record counts for key tables, such as users, collections and saved questions, between the H2 file and the loaded database.
Underestimating the migration lock during upgrades
Metabase runs application database migrations automatically at startup, and a migration lock prevents multiple nodes from running them at once. Teams that move the database and upgrade Metabase in the same window often run a multi-node cluster, which can stall or contend during migrations. Reduce the cluster to a single node for any major upgrade, back up the PostgreSQL database first, and restore the cluster only after the migrations complete.
Upgrading Metabase docsMismatched PostgreSQL connection and authentication settings
The new PostgreSQL server may enforce authentication settings the MySQL setup never met, such as SCRAM password authentication, which replaces MD5 in current releases. Connection limits and TLS requirements can also differ. Confirm the authentication method in pg_hba.conf, the role password encryption setting and the JDBC connection string before cutover, and test the connection from the Metabase host under its real network path.
Questions teams ask before moving the Metabase application database
How much effort does moving the Metabase application database from MySQL to PostgreSQL take?
The effort depends mostly on the size of the application database, how many Metabase instances share it, and how much of the surrounding setup has to change. The dump and load steps are short commands, so the work is usually in preparation and verification rather than in the commands themselves. Effort rises when the team has to rebuild the Metabase host, reconcile environment variables, update SSO and reverse proxy settings, or test the result against real users. Ask any partner for a written scope that lists each environment, each instance and each verification step, because that list is what drives the quote. Your own team will spend most of its time on access approvals, backup checks and the test run.
Can our own team run dump-to-h2 and load-from-h2 without outside help?
Yes, if your engineers can run the Metabase JAR, manage a MySQL or MariaDB instance, and provision a PostgreSQL database with the right version and encoding. Metabase documents dump-to-h2 for moving the existing application database into a new H2 file, and load-from-h2 for loading that file into PostgreSQL or MySQL. The critical detail is that load-from-h2 must run with the same Metabase version that last wrote the H2 file. Teams that have not done this before often benefit from a rehearsal in a non-production environment first. Outside help is most useful for the rehearsal, the cutover checklist and the rollback plan.
How long does the cutover window need to be, and what sets it?
The cutover window is the period when Metabase is stopped so no writes reach the old database while the dump is taken and loaded. Its length is set by the time needed to dump the application database, load it into PostgreSQL, start Metabase against the new database and check that dashboards, users and scheduled jobs behave correctly. The size of the database, the speed of the network between hosts and the number of verification checks are the main drivers. Your team should measure the dump and load time in a rehearsal on a copy of production data and use that measurement to set the window. Do not set the window from an assumed figure.
What does the work need from our team in access, backups, key custody and a test environment?
The team needs read access to the current application database host and the Metabase configuration, rights to create a PostgreSQL database and role, and a place to store the H2 file during the move. Take a full backup of the MySQL or MariaDB application database before starting, and keep it until the new setup has run successfully for a period you agree in advance. Key custody matters because Metabase uses an encryption key to protect stored secrets, and the same key must be available to the new instance; confirm where it is stored and who can retrieve it. A non-production environment with a copy of the data is needed to rehearse the full sequence, including the version match.
Does moving the application database also move our data warehouse data?
No. The application database holds Metabase's own content, including users, groups, permissions, saved questions, dashboards, collections and settings. The data warehouses and databases that Metabase queries stay where they are and are not copied by this move. After the cutover, the new Metabase instance must still be able to reach those data sources, so firewall rules, network routes and database credentials need to be checked from the new host. Confirm this list with your data platform owners before the cutover, because a working application database with broken warehouse connections looks like a failed migration to users.
Should we plan PostgreSQL high availability or PgBouncer in the same project?
Decide this before the move, but treat it as a separate design decision. PostgreSQL supports hot standby servers and both synchronous and asynchronous replication, but it does not include the software to detect a failed primary and promote a standby, so automatic failover needs external tools. PgBouncer is a connection pooler that can reduce connection overhead if many Metabase instances or services share one database. Including these in the same project adds design, testing and operating work, so they are usually easier to scope in a planned phase. Whatever you choose, confirm the PostgreSQL major version you will run. Supported versions are 18, 17, 16, 15 and 14, with end-of-support dates published by the PostgreSQL project, so check the dates for your chosen version and plan any later major upgrade early.
Which Metabase and PostgreSQL versions should we pick before starting?
Pick the Metabase version first, because load-from-h2 has to run with the same version that last wrote the H2 file. Check the Metabase version support page for the end-of-life date of the release you run, and plan any upgrade separately so the database move is not combined with a version change. For PostgreSQL, choose a version that is still within its published support window for the whole period you expect to run it. Confirm the chosen versions against the current release and support pages on the day you plan the work, because release dates and support windows change over time.
How the MySQL to PostgreSQL move flows through the H2 file
The move starts with the existing MySQL or MariaDB application database, which dump-to-h2 copies into a new H2 file. That file is the hand-off: load-from-h2 must run with the same Metabase JAR that last wrote it, and it loads the data into PostgreSQL. A pilot instance then points at PostgreSQL so you can compare it with the running system before cutover. The original MySQL database stays untouched as the rollback path until the new instance has been checked.
Application database phases, with the H2 file as the hand-off between MySQL and PostgreSQL.
How DeployOpen scopes and delivers this migration
DeployOpen is a Chainscore Labs company that plans, implements and supports self-hosted open-source platforms inside the client's own infrastructure, including their cloud accounts, data centers and air-gapped networks. For a Metabase application database move, that means the work runs against your Metabase hosts, your PostgreSQL target and your change windows, and the data never has to leave your environment. Most engagements of this kind are fixed-scope, so the written scope is the first deliverable and the place where the migration is defined before any file is dumped.
The written scope names the current Metabase version and the version that last wrote the H2 file, the MySQL or MariaDB source, the PostgreSQL version and topology chosen as the target, the number of Metabase nodes and whether a cluster will be reduced to a single node for the load, and the acceptance checks that prove the move worked. It also records the rollback plan, which should be a restorable backup of the MySQL application database taken before dump-to-h2 runs, with the original Metabase JAR and configuration kept available. Confirm with your team which encryption key and environment variables must carry over, since the scope should state how they are handled. Delivery then follows a fixed sequence: a rehearsal on a copy of the application database, a timed cutover in your change window, and a handover of runbooks, checks and the rollback procedure to your operators. Ongoing support, upgrades and continuous testing are available as a retainer once the handover is complete.

