Restoring H2 backup file to run metabase instance

How can i reuse the backed up H2 database file to run the metabase installation.

You need to use Environment variables

1 Like

Thank you

@Luiggi I was using this command with env variable:
sudo docker run -d -p 3000:3000 -e "MB_DB_FILE=/home/ubuntu/metabase.db" --name metabase metabase/metabase
In that file path, i have the file - metabase.db.mv.db
Getting this error like:
2023-06-06 12:46:53,610 INFO db.setup :: Verifying h2 Database Connection ...

org.h2.message.DbException: Log file error: "/home/ubuntu/metabase.db/metabase.db.trace.db", cause: "org.h2.message.DbException: Error while creating file ""/home/ubuntu"" [90062-212]" [90034-212]

org.h2.message.DbException: Log file error: "/home/ubuntu/metabase.db/metabase.db.trace.db", cause: "org.h2.message.DbException: Error while creating file ""/home/ubuntu"" [90062-212]" [90034-212]

at org.h2.message.DbException.get(DbException.java:212)

at org.h2.message.TraceSystem.logWritingError(TraceSystem.java:294)

at org.h2.message.TraceSystem.openWriter(TraceSystem.java:315)

at org.h2.message.TraceSystem.writeFile(TraceSystem.java:263)

at org.h2.message.TraceSystem.write(TraceSystem.java:247)

at org.h2.message.Trace.error(Trace.java:187)

at org.h2.engine.Database.(Database.java:395)

at org.h2.engine.Engine.openSession(Engine.java:92)

at org.h2.engine.Engine.openSession(Engine.java:222)

at org.h2.engine.Engine.createSession(Engine.java:201)

at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)

at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:122)

at org.h2.Driver.connect(Driver.java:59)

at java.sql/java.sql.DriverManager.getConnection(Unknown Source)

at java.sql/java.sql.DriverManager.getConnection(Unknown Source)

at metabase.db.data_source.DataSource.getConnection(data_source.clj:31)

at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)

at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:213)

at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176)

at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163)

at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)

at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908)

at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)

Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Log file error: "/home/ubuntu/metabase.db/metabase.db.trace.db", cause: "org.h2.message.DbException: Error while creating file ""/home/ubuntu"" [90062-212]" [90034-212]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:554)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)

... 23 more

Caused by: org.h2.message.DbException: Error while creating file "/home/ubuntu" [90062-212]

at org.h2.message.DbException.get(DbException.java:212)

at org.h2.store.fs.disk.FilePathDisk.createDirectory(FilePathDisk.java:348)

at org.h2.store.fs.FileUtils.createDirectory(FileUtils.java:85)

at org.h2.store.fs.FileUtils.createDirectories(FileUtils.java:382)

at org.h2.store.fs.FileUtils.createDirectories(FileUtils.java:381)

at org.h2.message.TraceSystem.openWriter(TraceSystem.java:305)

... 20 more

Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Error while creating file "/home/ubuntu" [90062-212]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:554)

at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)

... 26 more

Caused by: java.nio.file.AccessDeniedException: /home/ubuntu

at java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source)

at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)

at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)

at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(Unknown Source)

at java.base/java.nio.file.Files.createDirectory(Unknown Source)

at org.h2.store.fs.disk.FilePathDisk.createDirectory(FilePathDisk.java:339)

... 24 more

Have you copied the file inside the container?

No, I have copied that outside the container, in my EC2 local.

Just to add more context, it was able to create a directory called "metabase-data", but i couldn't read the backup file (metabase.db.mv.db) i place in that directory.

Figured out a solution using docker-compose, we can close this thread