From Neon
Tested with: Neon preset: offline fixtures (URL detection, rewrites, checklist) · sync/cutover end-to-end on PostgreSQL 17 · zb migrate 0.1
Neon runs PostgreSQL, so a Neon branch moves to a Databasezy PostgreSQL instance with pg_dump and, if you want near-zero downtime, logical replication.
| Status | Available |
|---|---|
| Target engines | PostgreSQL |
| How we read it | Connection string |
| Continuous sync | Yes, for PostgreSQL |
| Provider preset | neon |
Before you start
Section titled “Before you start”- A Databasezy PostgreSQL instance on the same or a newer major version, or use
--create. - The connection string of the branch your application writes to, for a role that owns the tables.
- For continuous sync: logical replication enabled on the Neon project.
Find the connection string
Section titled “Find the connection string”In the Neon console, open the project, pick the branch and choose Connect. Either the pooled or the direct string
works: the preset rewrites a -pooler host to the direct endpoint, because the pooler runs in transaction mode and
cannot serve pg_dump snapshots or replication.
Neon notes
Section titled “Neon notes”- Use the direct endpoint, not the "-pooler" hostname; pg_dump needs a session connection.
- Each Neon branch is a separate source; migrate the branch your app writes to.
- Logical replication must be enabled in the project settings before continuous sync.
The preset also adds sslmode=require and options=endpoint=<ep-id>, which routes clients that do not send SNI.
--dry-run prints the rewritten URL (code neon.pooler_rewritten). A child branch includes its parent’s data as of
the branch point; migrate other branches as separate instances.
Migrate
Section titled “Migrate”- Open the target PostgreSQL instance (create one first if you need to) and choose the Migrate in tab.
- Under Source, pick Connection string and paste the URL. The host is recognised as Neon; you can also pick it from the provider list.
- Choose Copy and sync to keep the target current until cutover, or Copy for a one-off copy.
- Run Preflight and work through the checklist. Blocking items must be fixed before the copy starts.
- Start the copy and follow Copy and Verify. Mismatches are listed per table or collection.
- When the sync lag is low, stop writes and choose Cut over. The Report step keeps the timings and verification results.
# Dry run: print the preflight checklist and the plan, change nothingzb migrate --from "postgresql://app_owner:[email protected]/app?sslmode=require" --to inst_abc --mode copy_and_sync --dry-run
# Start it (or use --create --size s1 instead of --to to create the target)zb migrate --from "postgresql://app_owner:[email protected]/app?sslmode=require" --to inst_abc --mode copy_and_sync
zb migrate status mig_123zb migrate cutover mig_123 # when status says ready_for_cutovercurl -sS https://api.databasezy.com/v1/orgs/$ZB_ORG/instances/inst_abc/migrations \ -H "Authorization: Bearer $ZB_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "source": { "kind": "connection_string", "url": "postgresql://app_owner:[email protected]/app?sslmode=require", "provider": "neon" }, "mode": "copy_and_sync"}'
# Follow progress, preflight report and verificationcurl -sS https://api.databasezy.com/v1/orgs/$ZB_ORG/instances/inst_abc/migrations/mig_123 -H "Authorization: Bearer $ZB_API_KEY"
# Cut over once the status is ready_for_cutovercurl -sS -X POST https://api.databasezy.com/v1/orgs/$ZB_ORG/instances/inst_abc/migrations/mig_123/actions/cutover -H "Authorization: Bearer $ZB_API_KEY"For copy and sync, turn on logical replication first (project settings, Logical Replication). This sets
wal_level=logical and restarts the computes. Preflight fails with pg.wal_level until it is on, and checks that the
role may replicate.
Verify
Section titled “Verify”Verification runs automatically after the copy and compares source and target: row counts per table, sequence or
AUTO_INCREMENT values, the number of indexes and a schema hash. A missing table or a short row count fails the
migration and lists what differs. Check the result with zb migrate status <mig_id> or the Verify step in the
portal, then run your application’s own smoke tests against the new instance before you switch traffic.
Continuous sync and cutover
Section titled “Continuous sync and cutover”With copy and sync, the target keeps receiving changes after the copy. When zb migrate status reports
ready_for_cutover (two lag samples in a row under 5 seconds):
- Stop writes to the source: maintenance mode, scale writers to zero, or revoke the application user.
- Run
zb migrate cutover <mig_id>(or Cut over in the portal). The agent drains the last changes, copies sequence values (PostgreSQL), verifies again and stops replication. If the target cannot catch up in time, the cutover is abandoned and sync keeps running; nothing changes on either side. - Point the application at the Databasezy connection string and resume writes.
zb migrate statusshows the measured downtime.
Schema changes are not replicated, so freeze migrations between the copy and cutover. Details: what happens at cutover.
Roll back
Section titled “Roll back”A migration never deletes anything on the source. Until you decommission it, rolling back means pointing the application back at the source.
- Before cutover: cancel with
zb migrate cancel <mig_id>. The publication, replication slot or replication channel the migration created is removed. - After cutover: writes made on Databasezy are not on the source. For PostgreSQL, start the migration with
--reverse-syncso the old database keeps receiving them after cutover and stays a valid fallback. Without it, copy the new data back with a migration in the other direction before you switch.
Troubleshooting
Section titled “Troubleshooting”Preflight says pg.wal_level
Section titled “Preflight says pg.wal_level”Logical replication is not enabled on the Neon project yet. Enable it, wait for the computes to restart, then run preflight again.
The copy stops with a connection reset
Section titled “The copy stops with a connection reset”A pooled endpoint was forced through. Use the direct endpoint, or let the preset rewrite the -pooler host.
Preflight cannot connect to the source
Section titled “Preflight cannot connect to the source”Check that the source accepts connections from the egress addresses preflight prints, that the host is the public one and that the password has not been rotated. zb migrate --dry-run shows the exact URL that will be used after any rewrites.
Preflight lists blocking items
Section titled “Preflight lists blocking items”Each item has a machine code and a fix. Nothing is written to the target until every blocking item is resolved; warnings do not block.
The restore stops on an extension
Section titled “The restore stops on an extension”The source uses an extension Databasezy does not ship. Drop it on the source if it is unused, or exclude the objects that depend on it with --exclude.
Sync is blocked with pg.wal_level or pg.replica_identity
Section titled “Sync is blocked with pg.wal_level or pg.replica_identity”Logical replication needs wal_level=logical on the source and a primary key (or REPLICA IDENTITY FULL) on every published table. Preflight lists the tables.
For anything else, zb migrate status <mig_id> shows the failing step and its message. How migrations work describes every step.