How to import database?

I used bellow command to import the database. but the database stay unchanged. what I have done wrong?

-U firezone
-d firezone
-h localhost
-p 15432 < /path2MyBackup/backup.sql

Here is what I have tried in the last a couple of days.
Created a new database and import my backup to the new database. same things, No data copied!
Web browser returned internal server error.

I then installed an external postgres. the data did copied to the external DB. however, It returned bunches
of functional errors when I executed “firezone-ctl reconfigure” command.
I have no ideas what I have done wrong. maybe my setup was not accurate?
I won’t be able to find any tutorial on how to setup firezone with external database.

Base on what I experienced, I believe some functions of backup.sql did not do it jobs right.
I suggest that it would be nice to give people an option to choose using the either default DB or an external DB when
installing firezone. This will save people lots of hire pulling.

Here is the biggest problems I have. I have no problems to backup the DB. but I have no ways to import them.

Hey willie,
Sorry for missing this. Could you take a look at Backup and restore - #10 by jamil to see if it helps with your issue?

I used bellow command to import the database. but the database stay unchanged. what I have done wrong?

I think you need to use the psql command to restore, not pg_dump. Like so:

-U firezone
-d firezone
-h localhost
-p 15432 < /path2MyBackup/backup.sql

As for using an external DB, keep in mind that Firezone encrypts some fields stored in the DB. The DB encryption key is stored locally on the Firezone host. If you’re trying to backup the configuration for a Firezone instance, you’ll need to backup the config directories @jason linked to above and the database.

If you’re simply trying to move all your data to an external DB without re-provisioning the Firezone host itself, you should be able to do that with something like the following steps:

  1. Backup your DB
  2. Import this to your external DB
  3. Edit your configuration, disabling the bundled Postgres service and setting connection parameters for your external DB. It should be a Postgres-compatible DB.
  4. firezone-ctl reconfigure
  5. At this point your Firezone instance should be pointing to the external DB.

If you’re hitting errors, post them here and we’ll take a deeper look.

Thank you Jamil for the quick response! I really appreciate it!

I just had a chance to give it try by using psql command as you were suggesting.
I dropped the existing database firezone and recreate an empty one with the same db name.
Now I can import the data to the database. however, the web browser still returned 502 gateway error.
I further dropped all the rows in devices table. Now I am back in business.
Importing the usernames is pretty much what I wanted it.

I haven’t tried importing the data to an external db yet.
As long as I can make it work in any way. I am happy.
I may experiment the second way in the future.

hopefully this tread may help others.
Thanks again!