Skip to the page

Guides · Shipping & operations

Rollbacks and restores

Recover from a bad deploy or write using the narrowest fix, from redeploying a query file to rewinding a single root or restoring a branch.

API
—
In the schema
—

What you’ll build#

This guide walks through recovering from a bad deploy or corrupted write in production. Recovery options span from redeploying a single query file up to rewinding an entire branch. Because broader restores discard more subsequent writes, always start with the narrowest fix that resolves the incident.

IncidentRecovery actionCollateral impact
Broken query logicRedeploy the prior query filesCollateral impactZero database rows reverted
Broken schema pushPush the prior schemaCollateral impactDrops fields added in the release along with values written to those fields
Corrupted writes under one rootRewind that root via napalm placement restore-rootCollateral impactReverts writes after --to for that root and its descendants only
Corrupted writes across a branchRestore the branch via napalm branches restoreCollateral impactReverts writes after --to across every branch sharing that shard

Database restores never undo external side effects. Emails sent, cards charged and third-party API calls triggered by actions or background jobs stay completed. To catch issues before rollout, see Release rehearsals.

Before you start#

Keep your project’s schema and query files tracked in git, and authenticate as an organization manager via napalm login or an org token with manage scope.

Point-in-time restores require cluster backups, and pinpointing the exact timestamp of a bad write requires cluster change-log storage. Verify both settings ahead of time.

Terminal
# Inspect current backup and change-log retention windowsnapalm storage show <cluster> # Extend backup retention starting from the next nightly snapshotnapalm storage keep <cluster> backups --days 30 # Enable cluster change-log storage if not yet activenapalm storage enable <cluster> log
Restore window
Every cluster includes 7 days of continuous point-in-time recovery reaching up to 60 seconds ago. Extending retention costs $50 for 14 days, $100 for 30 days or $250 for 90 days per cluster per month plus standard storage for retained snapshots and takes effect from the next nightly backup, so widen retention before a high-risk migration.
Change log
napalm changes reads the cluster’s change log and returns 409 change_log_not_configured if log storage is disabled.

Scale & recovery documents backup architecture and retention billing.

Find the bad change#

napalm activity lists recent org events alongside each actor, recording schema pushes as project schema migrated and query pushes as project queries deployed. napalm changes summarizes every commit on a branch by timestamp, caller class and mutated types without exposing row values.

Commit and deploy timeline

Compare control-plane deploys and data-plane commits to isolate the first bad change.

Inspect both logs over the incident window to find the clean timestamp immediately preceding the bad deploy or write.

Terminal
# List recent organization events newest first alongside each actornapalm activity --limit 20 # List main-branch commits over the past two hours by timestamp, caller and mutated typesnapalm changes notes --since 2h

--to accepts an RFC 3339 timestamp (or local time without an offset), and napalm activity --json exposes exact insertTime values.

Paging history
--since 1d widens the lookback window, and --after pages forward from the bookmark printed at the bottom of the output.
Sharded branches
The branch-wide change log does not yet cover multi-shard branches (409 branch_distributed). Use napalm activity --json or application logs to select your restore timestamp on sharded branches.

Roll back a deployed query#

Each deployed query maps to a file in dbschema/queries. Running napalm queries push compiles every file in that folder against main’s active schema and replaces the deployed catalog atomically without touching stored rows.

Terminal
# Revert the commit that introduced the broken querygit revert <commit> # Validate every query file against main's schema, then redeploy the catalognapalm queries push notes --checknapalm queries push notes
Connected repositories
Open and merge a revert pull request so your deployment pipeline pushes the restored catalog (see Environments & going live).
Dropping added queries
If the reverted commit introduced a new query file, redeploying removes that endpoint. Interactive pushes ask for confirmation first (--yes skips the prompt in CI).
Paired schema edits
Catalog pushes fail if any query fails to compile against main. When rolling back both schema and query changes, revert both commits and run napalm schema push so both migrate together.
Client rollout
Roll back your frontend or backend deployment alongside the query catalog so callers match the restored query signatures.

Roll back a schema change#

Revert the schema commit in git, preview the reverse DDL with napalm schema push notes --plan to inspect any destructive drops and apply the rollback migration alongside dbschema/queries.

Terminal
# Revert the commit that modified the schemagit revert <commit> # Preview the rollback DDL and destructive drops without applying changesnapalm schema push notes --plan # Apply the prior schema and query catalog in one migrationnapalm schema push notes
Added a property, link or type
Drops the added schema item along with any values written since the release (prompting before applying).
Modified an access policy
Restores the previous access policy immediately with zero data loss.
Added an index or constraint
Drops the index or constraint cleanly without modifying stored rows.
Dropped a property, link or type
Re-creates the schema definition empty (requiring a default or fill expression for required fields). Recovering dropped values requires a backup restore.

On GitHub-connected repositories, open a revert pull request so the PR comment previews the reverse plan and requests maintainer approval on any drop (see Branches).

Restore a single root#

Point-in-time recovery operates at two granularities depending on whether the branch is sharded across placement roots or runs on a single shard.

Single-root rewind

Sharded branches rewind one root subtree while every other tenant stays online.

Whole-branch shard restore

Single-shard branches rewind the entire branch in place behind the project URL.

On a sharded branch, napalm placement restore-root rewinds a single placement root (Account, Project, Site or Organization) and all of its rooted descendants from shard backups while every other root stays untouched.

Terminal
# Confirm the branch's roots are spread across shardsnapalm placement show notes # Rewind one placement root and its rooted descendants to an earlier timestampnapalm placement restore-root notes <root-id> --to 2026-11-14T16:20:00Z --wait
Sharded branch
napalm placement show must report the branch’s roots as spread across shards. Unsharded single-shard branches reject napalm placement restore-root and direct you to napalm branches restore.
Root UUID
Pass the UUID of the target root record (Account, Project, Site, Organization or any root type in your schema). The root must still hold rows on the branch. An unknown or empty root UUID returns 404 not_found.
Target timestamp
Any past timestamp within the owning shard’s backup retention window. Out-of-range timestamps return 400 invalid_request.
Later writes
Writes to that root and its rooted descendants after --to are discarded. Interactive runs prompt for confirmation unless --yes is passed.
Other branches
Pass --branch pr-12 to rewind a root on a non-main sharded branch. Concurrent placement moves or cluster operations return 409 cluster_busy.

Schema roots covers how root types and descendant ownership links are inferred or declared, and Multi-tenant B2B SaaS walks through sharding and rewinding tenant roots on a live project.

Restore a whole branch#

napalm branches restore rewinds an entire single-shard branch (main by default) in place to an earlier timestamp behind the same project URL, discarding all writes after --to.

Because a branch restore rewinds the underlying shard, every co-located branch on that shard rewinds to the same timestamp and shard traffic pauses until recovery finishes. Interactive runs list co-located branches before prompting, and non-interactive --yes runs require naming those exact branches in --with.

Terminal
# Interactive restore (lists any co-located branches on the shard before prompting)napalm branches restore notes --to 2026-11-14T16:20:00Z # Non-interactive restore explicitly naming co-located branches on the shardnapalm branches restore notes --to 2026-11-14T16:20:00Z --with dev-ada,pr-12 --yes
Error codeCause
409 shard_holds_branches--with omitted or mismatched the co-located branches on the shard (listed in the error response).
409 branch_newer_than_momentA branch on the shard was created after --to. Delete that branch first or choose a later timestamp.
409 branch_moved_after_momentA branch moved onto or off the shard, copied data or enabled placement after --to. Choose a later timestamp.
409 branch_distributedThe branch is sharded across multiple shards, shares the shard with a sharded branch or holds a core copy. Use napalm placement restore-root instead.
409 backups_not_configuredBackups are not enabled on the cluster.
409 cluster_busyAnother cluster or branch operation is already in progress.
400 invalid_request--to lies in the future or precedes branch creation.

Scale & recovery shows a full restore session, and the Schema & branches API exposes the same operation at POST /projects/{id}/branch-restores.

Reconcile external side effects#

Restores rewind PostgreSQL state while external calls made by actions and job handlers stay executed. Reconcile any outbound side effects or inbound webhooks that occurred after the restore timestamp.

Emails and charges
Transactional emails and card charges sent after --to are not reversed automatically. Issue refunds or follow-up notices directly through your payment or mail provider.
Handler writebacks
If a handler charged a card and wrote the receipt row via call.db() after --to, the restore removes the receipt row while the charge still stands at Stripe. Reconcile restored rows against your provider’s ledger.
Inbound webhooks
Rewinding removes InboundEvent deduplication rows committed after --to, and external providers do not automatically replay previously acknowledged webhooks. Redeliver events from the sender’s dashboard, because the unless conflict pattern in Receiving webhooks safely skips any event that predates the restore point.

Check the recovery setup#

  1. Verify backup retention

    napalm storage show <cluster> reports backups as on, kept 30 days after extending the window above.

  2. Locate a commit in the change log

    Create a note in your app and run napalm changes notes --since 10m to confirm the commit appears showing Note (1 added) under a session caller.

  3. Dry-run a schema rollback plan

    Check out the commit prior to your latest migration and run napalm schema push notes --plan to inspect the reverse DDL without modifying main.

  4. Verify restore confirmation prompts

    Run napalm branches restore notes --to targeting ten minutes ago, confirm the prompt lists any co-located branches on main’s shard and answer N to abort safely.

Type a word or two to search every docs page.