Migrated from H2 to Postgres, but still creates a new H2 DB

Metabase v0.42
PostgreSQL v12.10.1
I try to migrate from H2 to Postgres using the command;

java -DMB_DB_TYPE=postgres -DMB_DB_DBNAME=metabase -DMB_DB_PORT=5432 -DMB_DB_USER=postgres -DMB_DB_PASS=-DMB_DB_HOST=localhost -jar metabase.jar load-from-h2 metabase.db

It runs successfully with an [OK] at the end of the process. I check the Postgres DB, and can see that the migration is truly successful.

I also terminated any task which was running Metabase, copying out the metabase.db.mv.db and metabase.db.trace.db files to a separate location.

Afterwards, I created a service - using the wrapper class nssm to automatically run the the command "java -jar metabase.jar" without seeing the cmd.

I ran the newly created service and to my surprise, It created new copies of the files I had copied out - metabase.db.mv.db and metabase.db.trace.db, and treated the setup as a new installation.

I have tried everything I can, but the issue still persists.
Any help would be appreciated.

Hi @ajibade
The migration is a one-off process, you'll need to tell Metabase which application database to use after:
https://www.metabase.com/docs/latest/operations-guide/configuring-application-database.html#postgres

Hi @flamber. Yes I know, however, it seems to not recognise the environment variables
How do I include it in the service which is created.?

@ajibade Have a look here: https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-debian.html

Thanks for the suggestion @flamber. This looks like it only applies to Debian-based systems. Is there a walkaround for windows that doesn't compromise on security and exposes sensitive info?

@ajibade You need to make sure that the environment variables are only readable to the service user running Metabase. It's the same for every OS.

The problem I've got now is that when the service is running, I can see the Command Line details in the task manager, which includes the environment variables. This is a big issue for me, but that seems to be the only way I know how to go about it.
Do you suggest I set it them as SYSTEM ENVIRONMENT VARIABLES?
Sorry for the back and forth.

@ajibade You are not using environment variables, you are using Java parameters, which will show up in the process list, since it's part of the command.

Got it. This is what it looks like right now.

I guess I have to work with this If I want to be able to run it as a service.

@ajibade Exactly. You are not using environment variables. You have to use environment variables. Search the internet about how they work on Windows, it is not specific to Metabase.

Sorry for having to come back to this, but I have checked everywhere and can't seem to find a way to use Environment Variables while running metabase as a service.

@ajibade Anyone with full system access will always be able to see everything.
You should create a user, which is able to only access Metabase and define the environment variables for that user. I will recommend that you search the internet, since it has nothing to do with Metabase.
https://stackoverflow.com/questions/305870/accessing-environment-variables-from-windows-services

Otherwise you can use Metabase Cloud if you want someone else to take care of the hosting and security: https://www.metabase.com/pricing/

Thanks for the reply. I followed the steps and set the environment variables.
However, the service starts up but the site is not up. Also, the CPU utilisation is at 100%.
No logs to check what is wrong.
I do not want to mix issues together, so kindly advice on what to do.

@ajibade Since you are not posting exactly what you are doing, then it's difficult to help, but I don't use Windows, so you'll need to look at where to find the logs on Windows for services. Check the event logs.