Choose your path
There are two ways to proceed at this point:- Create a brand new database on this server. Follow the steps below to set the password, create the database, and configure roles.
- Import a database from a replica if you are recovering from a failed or compromised server. Use the Disaster recovery: dump from a replica instructions at the bottom of this page.
If you import from a replica, you can skip the database creation and seed steps and go straight to the restore instructions.
Set password and create database
Create the three role tiers
1. Superuser — full ownership
2. appuser — full CRUD on all tables (read, insert, update, delete)
3. appviewer — scoped access (mixed SELECT-only and read/write tables)
The exact list of which tables
appviewer can access, and at which permission level (SELECT-only vs. SELECT/INSERT/UPDATE), is maintained in the J-Spider-Store-Backend repo docs. Check there before granting or revoking access for this role — do not assume the same table list applies across environments.Remote access
For remote database work (DBeaver, pgAdmin, TablePlus, etc.), do not expose PostgreSQL directly to the internet. Use an SSH tunnel through the VPS instead — Postgres stays bound tolocalhost and only the SSH port is reachable.
1. Confirm Postgres is listening on localhost only
localhost only. Do not set it to '*', or remove the # to set an explicit value if you change it.
2. Check for exposed ports
localhost or 127.0.0.1 for port 5432. If you see 0.0.0.0:5432 or :::5432, it is exposed to the network.
3. Set up the SSH tunnel
DBeaver:- New connection → PostgreSQL
- Main tab: Host
localhost, Port5432, Databaseprod_db, User/Password of the role you’re connecting as - SSH tab: enable “Use SSH Tunnel” → Host/IP: your VPS IP, Port
22, User: your VPS SSH user, Auth: private key or password - Test Connection — DBeaver tunnels the connection through SSH automatically
- New Server → Connection tab: Host
localhost, Port5432, Maintenance DBprod_db, Username/Password - SSH Tunnel tab: enable tunneling → Tunnel host: VPS IP, Tunnel port
22, Username, Identity file (or password) - Save
Useful checks
Disaster recovery: dump from a replica
If the primary server is compromised, down, or lost, you can recover data from a PostgreSQL replica. On the new/replica server, dump the database locally:replica_dump.sql to a safe location and restore it into the new primary database:
Build the server
Once the database is restored, finish by generating the client, pulling the latest schema, and building the server:Use
pnpm build:prod if your repo uses a production build script.