pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL. In this blog, I will walk you through how to configure and use shared storage in pgAdmin 4.
What is Shared Storage in pgAdmin 4?
The shared storage option of pgAdmin allows multiple users to use a common directory on the pgAdmin server host machine for the storage of files such as SQL scripts or backups. It can be set up by admin users. This feature is available for server mode only. Admin users have full control over actions like deleting, uploading, renaming the files, and creating new folders in the shared directory.
How to set up Shared Storage?
To use shared storage, an administrator user needs to configure the SHARED_STORAGE setting in the config file (for more details please check the config_local.py file). The shared storage configuration looks like the below.
SHARED_STORAGE = [{
'name': Shared-Storage',
'path': '/var/pgadmin4/shared',
'restricted_access': True
},
{
'name': Code-Shared',
'path': '/var/pgadmin4/shared_folder/',
'restricted_access': False
}]
- name: Name to be displayed in pgAdmin file browser
- path: This is the absolute path of the shared directory on the host machine.
- restricted_access: If the user sets this to ‘True’, then shared storage will be read only for non admin users
Administrators can specify multiple shared storage areas with different access policies by passing them as a list of dictionaries containing specifications for each one. Note: You must ensure the directories specified are writeable by the user that owns the web server process. e.g. apache or www-data.*
How to use Shared Storage?
Once an administrator completes the shared storage setup, other admin and non-admin users can use it.
For example, if an administrator user wants to share a server configuration JSON file with all the pgAdmin users, the administrator can add that file into the shared storage.
The file can be added through the pgAdmin storage manager or directly copy the file to the shared directory.
Users can access shared storage from different navigation paths.
-
Storage Manager:
- Open Tools menu -> Storage Manager
- Click on the folder icon and it will open the dropdown.
- Here “Shared-Storage” and “Code-Shared” are shared storage areas and “My Storage” is user specific storage.
- You can easily switch between different storage areas by clicking on the name from the dropdown.
-
Query Tool:
- You can access the shared storage areas from Query tool as well.
- Open Query Tool
- Select Open File from the toolbar
- Now you can access shared storage from the drop down menu:
Conclusion
Using a shared storage administrator users can set up shared space that can be used by all other users for sharing files such as SQL scripts and backups. Admin users can also restrict the access to the shared storage to the non admin users.