Synology NAS Setup
Host PostgreSQL on your Synology NAS for a powerful, self-hosted database that you can access from anywhere.
What You'll Get
- ✓ PostgreSQL database on your NAS
- ✓ Access from any computer via Tailscale
- ✓ Full control over your data
- ✓ Automatic backups with Synology tools
Prerequisites
- Synology NAS (DS218+, DS220+, DS920+, etc.)
- Docker package installed from Package Center
- SSH access enabled (Control Panel → Terminal & SNMP)
- Basic familiarity with command line
Step 1: Create Folder Structure
- Open File Station on your Synology
- Navigate to the
dockershared folder - Create a new folder:
blackbook - Inside it, create:
db-data
# Final structure:
/volume1/docker/blackbook/
└── db-data/
Step 2: Create docker-compose.yml
SSH into your Synology and create the compose file:
# SSH to your NAS
ssh your-user@your-nas-ip
# Navigate to folder
cd /volume1/docker/blackbook
# Create compose file
nano docker-compose.yml
Paste this content:
version: '3.8'
services:
postgres:
image: postgres:15
container_name: blackbook-db
restart: unless-stopped
environment:
POSTGRES_USER: blackbook
POSTGRES_PASSWORD: your_secure_password_here
POSTGRES_DB: blackbook
ports:
- "5432:5432"
volumes:
- ./db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U blackbook"]
interval: 10s
timeout: 5s
retries: 5
⚠️ Important: Change your_secure_password_here to a strong password!
Step 3: Start the Database
# Start the container
sudo docker-compose up -d
# Check it's running
sudo docker ps
# View logs
sudo docker logs blackbook-db
You should see the container running and "database system is ready to accept connections" in the logs.
Step 4: Configure BlackBook
In the BlackBook setup wizard, select "Self-Hosted Server" and enter:
Host: your-nas-ip (or Tailscale hostname)
Port: 5432
Database: blackbook
Username: blackbook
Password: your_secure_password_here
SSL: Off (unless you configured SSL)
Step 5: Enable Remote Access
To access your database from outside your home network, use Tailscale:
- Install Tailscale on your Synology (Package Center or manually)
- Install Tailscale on your computer
- Sign in with the same account on both
- Use the Tailscale hostname instead of IP address
See Tailscale Setup Guide for detailed instructions.
Backup
Your PostgreSQL data is stored in /volume1/docker/blackbook/db-data.
Include this in your Synology backup tasks (Hyper Backup).
For database-level backups:
# Create a backup
sudo docker exec blackbook-db pg_dump -U blackbook blackbook > backup.sql
# Restore from backup
sudo docker exec -i blackbook-db psql -U blackbook blackbook < backup.sql
Troubleshooting
Container won't start
sudo docker logs blackbook-db
Check logs for permission or port conflicts.
Can't connect from BlackBook
- Verify the container is running:
sudo docker ps - Check firewall allows port 5432
- Try connecting with IP instead of hostname
- Verify password is correct
Port 5432 already in use
Change the port in docker-compose.yml:
ports:
- "5433:5432" # Use 5433 externally