13

How to import/export server lists between pgadmin 4.2 between computer (in Windows)?

I found some links for pgadmin 3 regarding registry. Would that be same for 4 too.

pgAdmin - Sharing DB Connection Definitions

2240
  • 1,547
  • 2
  • 12
  • 30
snowrock
  • 161
  • 1
  • 1
  • 8

3 Answers3

8

According to https://stackoverflow.com/a/45823367/89346, configuration data seems to be available in C:\Users\{Your_User}\AppData\Roaming\pgAdmin. You may try to copy the pgAdmin directory across different machines

shantanoo
  • 3,617
  • 1
  • 24
  • 37
8

Documentation exists for this, here: Exporting and importing Servers

When you install pgAdmin4 on Windows, e.g. C:\Program Files (x86)\pgAdmin 4\v4 for version pgAdmin4 v4.2 in my case, there is a subfolder named venv which hosts another Scripts subfolder in which is stored Python Virtual Environment mentioned in documentation.

This is the python.exe that we can use to dump the servers list. Open a command prompt (Win + R, cmd), and browse to this Scripts subdirectory

cd "C:\Program Files (x86)\pgAdmin 4\v4\venv\Scripts"

The command I used to create the dump is:

python.exe "C:\Program Files (x86)\pgAdmin 4\v4\web\setup.py" --dump-servers D:\dump\pgAdmin4_servers_list.json

If successful, message stating number of servers descriptions dumped will be displayed. In my case:

Configuration for 43 servers dumped to D:\dump\pgAdmin4_servers_list.json.

Then, copy the JSON file to the new computer and, using a command prompt, browse to the same subdirectory as before:

cd "C:\Program Files (x86)\pgAdmin 4\v4\venv\Scripts"

Before import, make sure pgAdmin4 server is shutdown. Now you can import the JSON file content (E: is my flash drive letter):

python.exe "C:\Program Files (x86)\pgAdmin 4\v4\web\setup.py" --load-servers E:\dump\pgAdmin4_servers_list.json

If successful, it should display the number of server groups and servers added. In my case:

Added 5 Server Group(s) and 43 Server(s).

Restart pgAdmin4 and you should see your server list as it was on the source.

Rafael
  • 48
  • 7
mimidatabase
  • 111
  • 1
  • 2
  • had to `set "PYTHONHOME=C:\Program Files (x86)\pgAdmin 4\v4\venv"` or was getting `failed to get the Python codec of the filesystem encoding` – basin Jul 16 '21 at 06:00
1

Just follow the below steps to Import and Export Servers list between pgAdmin 4 by using the pgAdmin application.

Export Server List

  • Open pgAdmin and click on Tools->Import/Export Servers
  • Import/Export UI will be poped-up
  • Select Export and locate your exported JSON file enter image description here
  • Select expected server information those you wanted to be exportedenter image description here
  • Click on finish button to complete export.

Import Server List

  • Same way you just need to click Import instead of export and browse your exported JSON file
  • Once you locate exported JSON file and follow the next instruction and finally click on the Finish button, server information will be imported.
Mahi
  • 1,019
  • 9
  • 19