H2 -> PostgreSQL migration failing because h2.db file cannot be found

Iโ€™m attempting to migrate my H2 database to PostgreSQL according to this document:

This is the error Iโ€™m seeing:

$ java -jar metabase.jar load-from-h2 /home/metabase/metabase.db.h2.db
11-17 09:26:52 INFO metabase.util :: Loading Metabase...
11-17 09:27:23 INFO metabase.db :: Verifying postgres Database Connection ...
11-17 09:27:23 DEBUG metabase.driver :: Registered driver :postgres ๐Ÿšš
11-17 09:27:24 INFO metabase.db :: Verify Database Connection ... โœ…
11-17 09:27:24 INFO metabase.db :: Running Database Migrations...
11-17 09:27:24 INFO metabase.db :: Setting up Liquibase...
11-17 09:27:24 INFO metabase.db :: Liquibase is ready.
11-17 09:27:24 INFO metabase.db :: Checking if Database has unran migrations...
11-17 09:28:09 INFO metabase.db :: Database Migrations Current ... โœ…
com.mchange.v2.cfg.DelayedLogItem [ level -> FINE, text -> "The configuration file for resource identifier 'hocon:/reference,/application,/c3p0,/' could not be found. Skipping.", exception -> null]
Temporarily disabling DB constraints...
[OK]
org.h2.jdbc.JdbcSQLException: Database "/home/metabase/metabase.db.h2.db" not found [90013-192]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
        at org.h2.message.DbException.get(DbException.java:179)
        at org.h2.message.DbException.get(DbException.java:155)
        at org.h2.engine.Engine.openSession(Engine.java:62)
        at org.h2.engine.Engine.openSession(Engine.java:176)
        at org.h2.engine.Engine.createSessionAndValidate(Engine.java:154)
        at org.h2.engine.Engine.createSession(Engine.java:137)
        at org.h2.engine.Engine.createSession(Engine.java:27)
        at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:349)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:118)
        at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:102)
        at org.h2.Driver.connect(Driver.java:72)
        at java.sql.DriverManager.getConnection(DriverManager.java:571)
        at java.sql.DriverManager.getConnection(DriverManager.java:187)
        at clojure.java.jdbc$get_connection.invokeStatic(jdbc.clj:272)
        at clojure.java.jdbc$get_connection.invoke(jdbc.clj:193)
        at metabase.cmd.load_from_h2$load_data_BANG_.invokeStatic(load_from_h2.clj:137)
        at metabase.cmd.load_from_h2$load_data_BANG_.invoke(load_from_h2.clj:136)
        at metabase.cmd.load_from_h2$load_from_h2_BANG_$fn__31435.invoke(load_from_h2.clj:211)
        at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:613)
        at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:585)
        at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:629)
        at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:585)
        at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:598)
        at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:585)
        at metabase.cmd.load_from_h2$load_from_h2_BANG_.invokeStatic(load_from_h2.clj:208)
        at metabase.cmd.load_from_h2$load_from_h2_BANG_.invoke(load_from_h2.clj:201)
        at clojure.lang.Var.invoke(Var.java:379)
        at metabase.core$load_from_h2.invokeStatic(core.clj:218)
        at metabase.core$load_from_h2.invoke(core.clj:211)
        at clojure.lang.AFn.applyToHelper(AFn.java:154)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.core$apply.invokeStatic(core.clj:646)
        at clojure.core$apply.invoke(core.clj:641)
        at metabase.core$run_cmd$fn__32188.invoke(core.clj:265)
        at metabase.core$run_cmd.invokeStatic(core.clj:265)
        at metabase.core$run_cmd.doInvoke(core.clj:264)
        at clojure.lang.RestFn.applyTo(RestFn.java:139)
        at clojure.core$apply.invokeStatic(core.clj:648)
        at clojure.core$apply.invoke(core.clj:641)
        at metabase.core$_main.invokeStatic(core.clj:279)
        at metabase.core$_main.doInvoke(core.clj:275)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at metabase.core.main(Unknown Source)
Command failed with exception: Database "/home/metabase/metabase.db.h2.db" not found [90013-192]

However, the file is clearly there when I look for it in the filesystem with ls. Could something else be causing this error?

Were you able to fix this? Iโ€™m getting the same error.

Try to run the migration program without specifying the h2 file, and put your h2 file on the same directory with your jar file(I assume this is the default location of the h2 file), then the migration program will load the h2 file on the default location. This works form me when migrating from h2 to mysql.

Youโ€™re not supposed to include the full extension of the DB file with H2; the path should end in metabase.db instead of metabase.db.h2.db. (These are the same rules as if you had specified the path DB file when running Metabase normally.)

You also donโ€™t need to specify it at all if you run the JAR from the same directory as the DB file.

1 Like

Thanks a lot, this worked for me.