Error While Migrating from H2 to PostgreSQL: File corrupted in chunk

I am following the instruction to migrate from H2 to postgreSQL but getting this error on version 0.44.6

Warning: protocol #'java-time.core/Amount is overwriting function abs
WARNING: abs already refers to: #'clojure.core/abs in namespace: java-time.core, being replaced by: #'java-time.core/abs
WARNING: abs already refers to: #'clojure.core/abs in namespace: java-time, being replaced by: #'java-time/abs
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
2023-01-25 21:43:13,916 INFO metabase.util :: Maximum memory available to JVM: 982.0 MB
2023-01-25 21:43:15,301 INFO util.encryption :: Saved credentials encryption is DISABLED for this Metabase instance. 🔓
 For more information, see https://metabase.com/docs/latest/operations-guide/encrypting-database-details-at-rest.html
WARNING: abs already refers to: #'clojure.core/abs in namespace: taoensso.encore, being replaced by: #'taoensso.encore/abs
WARNING: abs already refers to: #'clojure.core/abs in namespace: kixi.stats.math, being replaced by: #'kixi.stats.math/abs
WARNING: abs already refers to: #'clojure.core/abs in namespace: kixi.stats.test, being replaced by: #'kixi.stats.math/abs
WARNING: abs already refers to: #'clojure.core/abs in namespace: kixi.stats.distribution, being replaced by: #'kixi.stats.math/abs
2023-01-25 21:43:19,710 INFO driver.impl :: Registered abstract driver :sql  🚚
2023-01-25 21:43:19,713 INFO metabase.util ::  ⮦ Load driver :sql took 77.6 ms
2023-01-25 21:43:19,720 INFO driver.impl :: Registered abstract driver :sql-jdbc (parents: [:sql]) 🚚
2023-01-25 21:43:19,722 INFO metabase.util :: Load driver :sql-jdbc took 89.8 ms
2023-01-25 21:43:19,723 INFO driver.impl :: Registered driver :h2 (parents: [:sql-jdbc]) 🚚
2023-01-25 21:43:19,747 INFO driver.impl :: Registered driver :mysql (parents: [:sql-jdbc]) 🚚
2023-01-25 21:43:19,767 INFO driver.impl :: Registered driver :postgres (parents: [:sql-jdbc]) 🚚
2023-01-25 21:43:21,617 INFO metabase.core ::
Metabase v0.44.6 (5c6ae21 release-x.44.x)

Copyright © 2023 Metabase, Inc.

Metabase Enterprise Edition extensions are NOT PRESENT.
2023-01-25 21:43:21,666 INFO cmd.copy :: Set up h2 source database and run migrations...
2023-01-25 21:43:21,669 INFO db.setup :: Verifying h2 Database Connection ...
2023-01-25 21:43:28,141 INFO db.setup :: Successfully verified H2 1.4.197 (2018-03-18) application database connection. ✅
2023-01-25 21:43:28,144 INFO db.setup :: Running Database Migrations...
2023-01-25 21:43:28,145 INFO db.setup :: Setting up Liquibase...
2023-01-25 21:43:28,592 INFO db.setup :: Liquibase is ready.
2023-01-25 21:43:28,593 INFO db.liquibase :: Checking if Database has unrun migrations...
2023-01-25 21:43:30,326 INFO db.setup :: Database Migrations Current ...  ✅
2023-01-25 21:43:30,328 INFO db.data-migrations :: Running all necessary data migrations, this may take a minute.
2023-01-25 21:43:30,338 INFO db.data-migrations :: Finished running data migrations.
2023-01-25 21:43:30,339 INFO metabase.util :: Database setup took 8.7 s
2023-01-25 21:43:30,339 INFO cmd.copy :: [OK]
2023-01-25 21:43:30,340 INFO cmd.copy :: Set up postgres target database and run migrations...
2023-01-25 21:43:30,340 INFO db.setup :: Verifying postgres Database Connection ...
2023-01-25 21:43:31,053 INFO db.setup :: Successfully verified PostgreSQL 14.5 application database connection. ✅
2023-01-25 21:43:31,065 INFO db.setup :: Running Database Migrations...
2023-01-25 21:43:31,066 INFO db.setup :: Setting up Liquibase...
2023-01-25 21:43:31,109 INFO db.setup :: Liquibase is ready.
2023-01-25 21:43:31,110 INFO db.liquibase :: Checking if Database has unrun migrations...
2023-01-25 21:43:32,272 INFO db.liquibase :: Database has unrun migrations. Waiting for migration lock to be cleared...
2023-01-25 21:43:32,494 INFO db.liquibase :: Migration lock is cleared. Running migrations...
2023-01-25 21:43:46,828 INFO db.setup :: Database Migrations Current ...  ✅
2023-01-25 21:43:46,829 INFO metabase.util :: Database setup took 16.5 s
2023-01-25 21:43:46,830 INFO cmd.copy :: [OK]
2023-01-25 21:43:46,830 INFO cmd.copy :: Testing if target postgres database is already populated...
2023-01-25 21:43:46,835 INFO cmd.copy :: [OK]
2023-01-25 21:43:46,835 INFO cmd.copy :: Clearing default entries created by Liquibase migrations...
2023-01-25 21:43:46,837 INFO cmd.copy :: Temporarily disabling DB constraints...
2023-01-25 21:43:47,826 INFO cmd.copy :: [OK]
2023-01-25 21:43:55,238 INFO cmd.copy :: Re-enabling DB constraints...
2023-01-25 21:43:55,238 INFO cmd.copy :: [OK]
2023-01-25 21:43:55,239 INFO cmd.copy :: [OK]
2023-01-25 21:43:55,246 INFO cmd.copy :: Temporarily disabling DB constraints...
2023-01-25 21:43:55,482 INFO cmd.copy :: [OK]
2023-01-25 21:43:55,520 INFO cmd.copy :: Copying instances of Database...
2023-01-25 21:43:55,540 INFO cmd.copy ::  copied 7 instances.
2023-01-25 21:43:55,546 INFO cmd.copy :: Copying instances of User...
2023-01-25 21:43:55,560 INFO cmd.copy ::  copied 7 instances.
2023-01-25 21:43:55,569 INFO cmd.copy :: Copying instances of Setting...
2023-01-25 21:43:55,614 INFO cmd.copy ::  copied 35 instances.
2023-01-25 21:43:55,633 INFO cmd.copy :: Copying instances of Table...
2023-01-25 21:43:55,704 INFO cmd.copy ::  copied 408 instances.
2023-01-25 21:43:58,996 INFO cmd.copy :: Re-enabling DB constraints...
2023-01-25 21:43:58,996 INFO cmd.copy :: [OK]
org.h2.jdbc.JdbcSQLException: General error: "java.lang.IllegalStateException: File corrupted in chunk 315043, expected page length 4..768, got -822014074 [1.4.197/6]"; SQL statement:
SELECT * FROM metabase_field ORDER BY id ASC [50000-197]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
        at org.h2.message.DbException.get(DbException.java:168)
        at org.h2.message.DbException.convert(DbException.java:307)
        at org.h2.command.Command.executeQuery(Command.java:216)
        at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:114)
        at clojure.java.jdbc$execute_query_with_params.invokeStatic(jdbc.clj:1090)
        at clojure.java.jdbc$execute_query_with_params.invoke(jdbc.clj:1084)
        at clojure.java.jdbc$db_query_with_resultset_STAR_.invokeStatic(jdbc.clj:1106)
        at clojure.java.jdbc$db_query_with_resultset_STAR_.invoke(jdbc.clj:1093)
        at clojure.java.jdbc$reducible_query$reify__28563.reduce(jdbc.clj:1357)
        at clojure.core$transduce.invokeStatic(core.clj:6946)
        at clojure.core$transduce.invoke(core.clj:6933)
        at metabase.cmd.copy$copy_data_BANG_.invokeStatic(copy.clj:172)
        at metabase.cmd.copy$copy_data_BANG_.invoke(copy.clj:164)
        at metabase.cmd.copy$fn__83004$copy_BANG___83009$fn__83010$fn__83019$fn__83020$fn__83021.invoke(copy.clj:359)
        at metabase.cmd.copy$do_with_disabled_db_constraints.invokeStatic(copy.clj:264)
        at metabase.cmd.copy$do_with_disabled_db_constraints.invoke(copy.clj:260)
        at metabase.cmd.copy$fn__83004$copy_BANG___83009$fn__83010$fn__83019$fn__83020.invoke(copy.clj:358)
        at metabase.cmd.copy$do_with_connection_rollback_only.invokeStatic(copy.clj:206)
        at metabase.cmd.copy$do_with_connection_rollback_only.invoke(copy.clj:204)
        at metabase.cmd.copy$fn__83004$copy_BANG___83009$fn__83010$fn__83019.invoke(copy.clj:356)
        at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:807)
        at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:776)
        at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:852)
        at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:776)
        at clojure.java.jdbc$db_transaction_STAR_.invokeStatic(jdbc.clj:789)
        at clojure.java.jdbc$db_transaction_STAR_.invoke(jdbc.clj:776)
        at metabase.cmd.copy$fn__83004$copy_BANG___83009$fn__83010.invoke(copy.clj:353)
        at metabase.cmd.copy$fn__83004$copy_BANG___83009.invoke(copy.clj:331)
        at metabase.cmd.load_from_h2$load_from_h2_BANG_.invokeStatic(load_from_h2.clj:35)
        at metabase.cmd.load_from_h2$load_from_h2_BANG_.invoke(load_from_h2.clj:25)
        at clojure.lang.Var.invoke(Var.java:384)
        at metabase.cmd$load_from_h2.invokeStatic(cmd.clj:45)
        at metabase.cmd$load_from_h2.invoke(cmd.clj:39)
        at clojure.lang.AFn.applyToHelper(AFn.java:154)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$apply.invoke(core.clj:662)
        at metabase.cmd$run_cmd$fn__83823.invoke(cmd.clj:227)
        at metabase.cmd$run_cmd.invokeStatic(cmd.clj:227)
        at metabase.cmd$run_cmd.invoke(cmd.clj:218)
        at clojure.lang.Var.invoke(Var.java:388)
        at metabase.core$run_cmd.invokeStatic(core.clj:167)
        at metabase.core$run_cmd.invoke(core.clj:165)
        at metabase.core$_main.invokeStatic(core.clj:189)
        at metabase.core$_main.doInvoke(core.clj:184)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at metabase.core.main(Unknown Source)
Caused by: java.lang.IllegalStateException: File corrupted in chunk 315043, expected page length 4..768, got -822014074 [1.4.197/6]
        at org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:870)
        at org.h2.mvstore.Page.read(Page.java:652)
        at org.h2.mvstore.Page.read(Page.java:186)
        at org.h2.mvstore.MVStore.readPage(MVStore.java:1936)
        at org.h2.mvstore.MVMap.readPage(MVMap.java:698)
        at org.h2.mvstore.Page.getChildPage(Page.java:208)
        at org.h2.mvstore.Cursor.fetchNext(Cursor.java:150)
        at org.h2.mvstore.Cursor.next(Cursor.java:50)
        at org.h2.mvstore.db.TransactionStore$TransactionMap$2.fetchNext(TransactionStore.java:1509)
        at org.h2.mvstore.db.TransactionStore$TransactionMap$2.next(TransactionStore.java:1559)
        at org.h2.mvstore.db.TransactionStore$TransactionMap$2.next(TransactionStore.java:1494)
        at org.h2.mvstore.db.MVPrimaryIndex$MVStoreCursor.next(MVPrimaryIndex.java:404)
        at org.h2.index.IndexCursor.next(IndexCursor.java:316)
        at org.h2.table.TableFilter.next(TableFilter.java:502)
        at org.h2.command.dml.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1452)
        at org.h2.result.LazyResult.hasNext(LazyResult.java:79)
        at org.h2.result.LazyResult.next(LazyResult.java:59)
        at org.h2.command.dml.Select.queryFlat(Select.java:527)
        at org.h2.command.dml.Select.queryWithoutCache(Select.java:633)
        at org.h2.command.dml.Query.queryWithoutCacheLazyCheck(Query.java:114)
        at org.h2.command.dml.Query.query(Query.java:371)
        at org.h2.command.dml.Query.query(Query.java:333)
        at org.h2.command.CommandContainer.query(CommandContainer.java:114)
        at org.h2.command.Command.executeQuery(Command.java:202)
        ... 44 more
Command failed with exception: General error: "java.lang.IllegalStateException: File corrupted in chunk 315043, expected page length 4..768, got -822014074 [1.4.197/6]"; SQL statement:
SELECT * FROM metabase_field ORDER BY id ASC [50000-197]

Can someone please help here?

Please see this other thread Metabase stuck at startup (File corrupted in chunk) - #3 by turker.tunali. Seems like the file is corrupted

Yeah. I figured out that it might be a curreption in the db file. However, metabase runs fine using the same file. I can't take a backup as the backup itself shows this error but as said metabase application works fine with no issue. The issue appears only when migrating or upgrading the metabase version. Can you please help?

We can't unfortunately, as that's a corruption error. I would suggest you check how you can fix that corrupted file and get out of H2