Hey, just wanted to share my tiny tool with the community.
This is an OSS CLI tool that helps you manage databases locally during development.
https://github.com/le-vlad/pgbranch
Why did I build this?
During the development, I was quite often running new migrations in a local feature branch; sometimes they were non-revertible, and going back to the main branch, I realized that I had broken the database schema, or I just needed to experiment with my data, etc.
This is a simple wrapper on top of PostgreSQL's CREATE DATABASE dbname TEMPLATE template0;
Appreciate your thoughts on the idea.
Pg_branch: Experimental Postgres extension brings Neon-like branching
How are you managing isolated Postgres database branches for preview deployments /CI?
pgbranch - git-style branching for PostgreSQL
Videos
Hey everyone, Iโm looking at workflows to optimise how we spin up staging databases for app previews. Iโve been experimenting Neonโs serverless architecture (specifically looking at how Databricks integrates it for Lakebase) to use its instant database branching.
Being able to use a Vercel integration to automatically spin up an isolated database branch for a preview deployment, run schema migrations, test a data app and tear it down without duplicating storage costs or impacting production seems like a massive win for modern dev.
For those running serverless Postgres in production, are you relying heavily on these types of branching workflows, or are you still doing it in the old fashioned way with Docker or isolated RDS staging instances.
Built this over the past week to solve my own problem: switching git branches breaks my local PostgreSQL database.
The migrations from your feature branch are still applied, and sometimes you can't just roll them back - the feature schema isn't compatible with main, or you've modified data in ways that don't work with the old code, or you've deleted rows that the old branch expects to exist. Your options are drop and re-seed (slow), or maintain multiple databases and juggle connection strings (annoying).
What it does
Creates instant snapshots of your PostgreSQL database using template databases. Switch between database states like git branches:
pgbranch branch main # snapshot current state
pgbranch checkout main # restore to that state instantly
No pg_dump for local operations. Template databases are file-level copies - fast even for large databases.
Why I'm posting here
-
Single Go binary - no runtime dependencies beyond PostgreSQL's own tools (psql, createdb, dropdb)
-
No cloud required - everything runs locally, nothing phones home (unless you want to share with the team)
-
Filesystem remote support - share snapshots via NAS, network share, or mounted drive. No S3 needed.
-
Simple config - single .pgbranch.json file, no separate database for the tool
Cloud remotes (S3, R2) are supported if you want them.
What it doesn't do
-
Production use - this is for local development only
-
Incremental backups - each snapshot is a full copy
-
It's a week old - works for my workflow but still early
Setup
go install github.com/le-vlad/pgbranch/cmd/pgbranch@latest
pgbranch init -d myapp_dev
pgbranch branch main
For sharing across machines:
pgbranch remote add nas /mnt/nas/pgbranch-snapshots
pgbranch push main
# on another machine
pgbranch pull main
GitHub: https://github.com/le-vlad/pgbranch
If you self-host PostgreSQL for development, I'd appreciate feedback. What's missing? What would make this useful for your setup?