How to migrate from managed database to self-hosted Postgres in 2026
We are paid if you buy through an 'Order' link. 'Visit' links pay us nothing.
Prices in this guide, checked 28 Nov 2026
Webdock VPS Essential1 vCPU, 2 GB, 15 GB NVMe
$2.36/mo before tax · billed €2.15 (euro rate of 27 Nov 2026)checked 28 Nov 2026
DigitalOcean Basic 512MB1 vCPU, 0.5 GB, 10 GB SSD
$4/mo before taxchecked 28 Nov 2026
Hetzner CPX021 vCPU, 1 GB, 20 GB NVMe
$8.09/mo before tax · $7.49 server + $0.60 IPv4 · Germany; $6.59 in Helsinkichecked 28 Nov 2026
How we pick: the plans this guide names, then the providers it names, then the cheapest we would pick, in that order, each one you can order today; cheapest first within each of the three. Figures in the text below were written 22 Sep 2026. Prices in this table were checked 28 Nov 2026 on each provider's own site. How we check prices
Managed databases (DigitalOcean Managed Postgres at $15/mo, AWS RDS at $17+/mo, Neon at $19+/mo) are convenient but expensive at scale. Migrating to self-hosted Postgres on your VPS often cuts your database bill by 50-90%. Whether that's worth the operational responsibility depends on your workload and your comfort with running a database yourself.
Figures in this text were written 22 Sep 2026.
The cost delta
| Current managed service | Self-hosted equivalent | Monthly saved |
|---|---|---|
| DO Managed Postgres 1 GB ($15) | Postgres on Hetzner CX22 ($4.60) | $10.40 |
| DO Managed Postgres 4 GB ($60) | Postgres on Hetzner CX32 ($7.60) | $52.40 |
| DO Managed Postgres 8 GB ($105) | Postgres on Hetzner CCX23 dedicated (~$32) | $73 |
| AWS RDS db.t3.micro ($17) | Postgres on Hetzner CX22 ($4.60) | $12.40 |
| Neon Scale 1 GB ($19) | Postgres on Hetzner CX22 ($4.60) | $14.40 |
Annualized, this ranges from $124/year saved (small workload) to $876/year (medium) or more.
When migration makes sense
- You've had a stable database for 6+ months and your workload is understood.
- You're comfortable operating Postgres (or willing to learn: backups, tuning, monitoring, restore drills).
- The saved money materially matters to your budget.
- You don't need the specific managed features (automatic failover, PITR without setup, one-click point-in-time restore).
When to stay on managed
- Your business depends on the database being up. Managed HA is real value.
- You've had a restore-that-didn't-work incident. Managed PITR is minutes; self-hosted restore drills need practice.
- You have SOC 2 or HIPAA compliance requirements with the managed service in your compliance envelope.
- Your DB grows unpredictably and you value the resize-with-a-click feature.
Step-by-step migration
1. Provision the target VPS
For the DB size you have on managed:
- Under 5 GB DB: Hetzner CX22 at $4.60/mo (2 vCPU / 4 GB).
- 5-20 GB DB: Hetzner CX32 at $7.60/mo (4 vCPU / 8 GB).
- 20-50 GB DB: Hetzner CX52 at ~$28/mo (8 vCPU / 32 GB) or dedicated (CCX23).
- 50+ GB DB: dedicated hardware (Hetzner CCX line or bare metal).
2. Install Postgres
Follow our Postgres install guide. Use the same major version as your managed service.
3. Tune Postgres for the VPS size
At install time, run pgtune.leopard.in.ua with your specs, copy the output into postgresql.conf, restart.
4. Take a backup from the managed service
DigitalOcean Managed Postgres:
pg_dump -F c \
--host=your-managed-cluster.db.ondigitalocean.com \
--port=25060 \
--username=doadmin \
--dbname=defaultdb \
--no-owner --no-acl \
> /tmp/db.dump
AWS RDS:
pg_dump -F c \
--host=your-rds.us-east-1.rds.amazonaws.com \
--port=5432 \
--username=your-rds-user \
--dbname=mydb \
> /tmp/db.dump
Neon:
pg_dump -F c \
--host=your-neon-hostname.neon.tech \
--username=your-user \
--dbname=neondb \
> /tmp/db.dump
5. Copy to your VPS
scp /tmp/db.dump deploy@your-vps:/tmp/
6. Restore on the VPS
sudo -u postgres createdb mydb
sudo -u postgres pg_restore -d mydb --no-owner --no-acl /tmp/db.dump
Check row counts against source to verify:
psql -c "SELECT COUNT(*) FROM users;" mydb
# Compare against source
7. Cutover
Two paths:
Path A: 5-15 minutes downtime (simplest)
1. Put app in maintenance mode.
2. Take a final pg_dump of source (only new data since first dump if you kept a snapshot; otherwise full dump).
3. Restore the delta.
4. Update app config to point at new DB.
5. Bring app back up.
Path B: near-zero downtime (with logical replication)
See How to migrate a database between VPS providers — same pattern applies, source is managed instead of another VPS.
8. Verify
- Application works normally.
- All rows present.
- Sequences point at correct next values.
- Any Postgres extensions (postgis, pg_trgm, uuid-ossp) are installed on the new DB.
9. Set up backups on the new DB
Non-negotiable. See our automated backups guide or the Postgres install guide's backup section.
Test a restore. If your backup doesn't restore cleanly, you don't have a backup.
10. Cancel the managed service
Take a final export, download the dump for insurance, cancel. Keep the dump for 60 days.
What you gain
- 50-90% cost reduction on your database bill.
- Full control over Postgres config, extensions, indexes.
- Same physical box as your app — potentially faster than a managed DB in a different datacenter.
What you take on
- Backup discipline. Your problem now.
- Postgres version upgrades. Major version bumps take real planning.
- Failover. If the box dies, you're down until you restore.
- Tuning. Postgres tuning is a real skill; managed services do this for you.
- Monitoring. Set up Netdata or Prometheus + postgres_exporter.
Where this migration is popular
- Small SaaS at profitability boundary. Every $50/mo saved on managed DB moves the needle.
- Personal projects. Managed DB is often 3-6x the total VPS bill.
- Multi-tenant B2B where each tenant is a small DB. Managed pricing balloons; self-hosted stays cheap.
Where it's a bad idea
- You've had one incident. Managed services exist for a reason.
- You're not paged when the DB is down. Nobody else will notice.
- You value your time. Managed DB is often cheaper than the ops overhead you take on.
Related guides
- How to install PostgreSQL on any Linux VPS — the install and tuning.
- How to migrate a database between VPS providers — the migration patterns.
- Best hosting for a Postgres database server — the hosting options.
- DigitalOcean to Hetzner migration — includes the managed-Postgres-to-self-hosted case.
Figures in this text were written 22 Sep 2026.
