-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
PostgreSQL
PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development. This package includes PostGIS spatial database extension for DSM 7+.
- Install the PostgreSQL package from SynoCommunity repository
- During installation, create an administrator account with username and password
- The default port is 5433 (to avoid conflict with Synology's built-in PostgreSQL on 5432)
Important: You must use the full path /usr/local/bin/ to run these commands, otherwise DSM's built-in PostgreSQL (on port 5432) will be used instead.
/usr/local/bin/psql -h localhost -p 5433 -U pgadmin -d postgres/usr/local/bin/psql -h /var/packages/postgresql/var -p 5433 -U pgadmin -d postgres| Command | Description |
|---|---|
psql |
PostgreSQL interactive terminal |
pg_dump |
Dump a database to a file |
pg_dumpall |
Dump all databases to a file |
pg_restore |
Restore a database from a dump file |
createdb |
Create a new database |
dropdb |
Remove a database |
createuser |
Create a new user role |
dropuser |
Remove a user role |
pg_isready |
Check if server is running |
vacuumdb |
Vacuum a database (reclaim storage) |
reindexdb |
Reindex a database |
clusterdb |
Cluster a database |
You can set up DSM scheduled tasks to run maintenance commands. Create a scheduled task with the following:
/usr/local/bin/vacuumdb -h localhost -p 5433 -U pgadmin -d mydatabase/usr/local/bin/reindexdb -h localhost -p 5433 -U pgadmin -d mydatabase/usr/local/bin/pg_dump -h localhost -p 5433 -U pgadmin -Fc mydatabase -f /volume1/backup/mydatabase.dumpIf you're running on DSM 7+ (GCC 5+), PostGIS is automatically enabled for all new databases. To enable PostGIS manually:
CREATE EXTENSION IF NOT EXISTS postgis;- Default authentication is scram-sha-256 (stronger than md5)
- The wizard enforces password complexity requirements
- Local connections use peer authentication (socket must be owned by PostgreSQL user)
Ensure you're using port 5433 (not the default 5432):
/usr/local/bin/psql -h localhost -p 5433 -U pgadmin -d postgres/usr/local/bin/pg_isready -h localhost -p 5433Logs are available at /var/packages/postgresql/var/log/
- Home
- Packages
- Concepts
- Development
- Resources