Migrating Zitadel from CockroachDB to PostgreSQL

Self-hosted Zitadel installations that run on CockroachDB need a planned move to PostgreSQL before the CockroachDB path is retired. This page explains how the zitadel mirror workflow, target preparation and verification fit together.

On this page

Why and when to migrate Zitadel from CockroachDB to PostgreSQL

If your self-hosted Zitadel runs on CockroachDB and you need to move it to PostgreSQL, the supported route is a data move: you prepare an empty PostgreSQL target and copy the data across with the zitadel mirror command, rather than swapping binaries under a running database. Zitadel supports PostgreSQL versions 14 through 18 as its database, so choose a target within that range that your own support policy allows. The Zitadel mirror documentation describes the copy, which runs against a destination initialized with zitadel init and zitadel setup --for-mirror, and it can run at system or instance scope. Plan the move as its own project with a named owner, a rehearsal and a cutover window, because the data, not the binary, is what must arrive intact.

This page sits beside the Zitadel v2 to v3 upgrade path, where CockroachDB support was removed. If you are still on v2, read the upgrade sequence first, since the order of steps in that path determines when this migration must land. Confirm the target Zitadel version against the zitadel/zitadel releases page before you start, because the setup and mirror steps depend on the release you deploy. Also confirm your current Zitadel version against the same page so the source and target agree on the schema.

PostgreSQL is released under the PostgreSQL License, a permissive open source license similar to the BSD and MIT licenses, so the database itself adds no licensing obligation for most internal deployments. Support windows matter more for planning. PostgreSQL releases a new major version about once a year and supports each major version for five years after its initial release. Version 14 is supported until November 12, 2026, while 18 runs until November 14, 2030, so a target chosen now should be checked against the PostgreSQL versioning policy to avoid moving again within a year.

What changes when Zitadel moves from CockroachDB to PostgreSQL

This table compares each part of a Zitadel installation that changes when the database moves from CockroachDB to PostgreSQL, with the impact and the action to take. Read it top to bottom before scheduling the cutover, since the empty target and the verification gate determine whether the move can proceed.

AreaWhat changesAction needed
Database backendZitadel stores its data in PostgreSQL instead of CockroachDB, so the source and destination use different engines.Confirm the Zitadel release you run supports the PostgreSQL target and plan the move as a data copy, not an in-place switch.
CockroachDB supportCockroachDB support was removed in the v3 line, so the current runtime no longer uses it as a backend.Identify whether your installation is still on CockroachDB and confirm the version you are migrating from before choosing the path.
PostgreSQL targetsSelf-hosted Zitadel supports PostgreSQL 14 through 18. PostgreSQL 14 support ends November 12, 2026.Choose PostgreSQL 15 to 18 for a target that remains supported longer, and confirm the version against the Zitadel database documentation.
Empty targetThe mirror copies into a destination that must be initialized with zitadel init and zitadel setup --for-mirror first.Provision a new empty PostgreSQL database, run init and setup --for-mirror, and do not reuse a database that holds data.
Mirror scopeThe mirror runs at --system or --instance scope, so the copied data depends on which scope you select.Decide the scope before the first run and record it, since repeat runs must use the same scope.
Verification gatezitadel mirror verify reports differences between source and destination.Treat a clean verify result as the gate for cutover, and rerun the mirror until differences are resolved.
Connection settingsApplication and setup configuration point at the database host, port, credentials and TLS options that change with the new engine.Update connection settings and secrets for every component, then test login and administrative functions against PostgreSQL.
BackupsBackup jobs and restore procedures written for CockroachDB do not cover the PostgreSQL database.Set up PostgreSQL backups and a tested restore before cutover, and retire the old CockroachDB backup jobs only after the new ones are verified.

How to prepare the PostgreSQL target and backups

Preparation decides whether the cutover is a rehearsed step or an improvised one. The cards below cover the safety net you need before touching production, the target you build for the mirror, and the copies you test against. Each one feeds the next, so skipping a card usually shows up as a failed verify or an unrecoverable rollback later.

Current CockroachDB backup and restore test

Confirm that your existing CockroachDB backups restore cleanly into a separate cluster before you change anything. A backup you have never restored is an assumption, not a rollback plan. Record who runs the restore, how long it took in your environment, and which Zitadel version was writing to the database at the time. Keep this backup until the PostgreSQL installation has been running in production for a period your operations team has agreed on.

Sizing and choosing a supported PostgreSQL major version

Select a PostgreSQL major version that Zitadel supports and that is still inside its community support window on your planned go-live date. Check the supported range in the Zitadel database documentation and the end-of-life dates in the PostgreSQL versioning policy, then confirm both against your own change calendar. Size storage and connections from the CockroachDB data you are copying, not from an estimate, and ask your database team to confirm backup and replication options for the chosen version.

Zitadel database docs

Creating an empty target database

Provision a PostgreSQL instance that contains no Zitadel data, with the roles, network paths and TLS settings your Zitadel pods or binaries will use. The mirror process expects the destination to be initialized by Zitadel init and setup --for-mirror, so any leftover tables from a test run will cause confusion. Document the connection string, the database and role names, and who owns each one. Confirm the cluster is isolated from production traffic until cutover.

A staging copy of the source

Create a staging copy of the CockroachDB data so you can run the full mirror, verification and application tests without touching live users. Ask your platform team to confirm how the copy is taken, whether it is consistent at a single point in time, and how its freshness will be handled during the rehearsal. Note the time between the copy and the first real migration run, because the gap determines how much delta the final cutover must absorb.

Inventory of configuration and secrets, including the masterkey

List every configuration value that Zitadel reads, including database credentials, TLS material, external domains and the masterkey used to protect encrypted data. The masterkey must be the same on the new deployment or encrypted values cannot be read, so store it in your approved secrets system and confirm access before the cutover window. Also record SMTP, identity provider and signing key settings, and whether any are managed through Helm values, environment variables or files.

A rehearsal environment

Build a separate environment that mirrors the target topology, including the same Zitadel version, PostgreSQL version and network controls. Run the full sequence there at least once, time each step in your own environment, and capture the verify output as evidence. Use the rehearsal to settle the rollback decision, the order of application restarts and who signs off each stage. Treat any step that needed manual intervention as a blocker until it is written into a runbook.

How the zitadel mirror command copies data

The mirror flow has three stages: prepare an empty PostgreSQL target, copy the data from CockroachDB, and then verify the copy before anyone changes the production connection. The target must be initialized first with zitadel init and then prepared with zitadel setup --for-mirror, so the schema exists before any rows arrive. Run these against the PostgreSQL connection settings you intend to use in production, because a mismatch in database names, users or TLS settings found at cutover is much harder to fix. The mirror itself is then started with the zitadel mirror command, pointed at the CockroachDB source and the prepared PostgreSQL destination. Confirm the exact flags and config keys against the mirror command reference before scripting them, since the names are not repeated here.

The scope choice decides what moves. With --system, the mirror covers instance-independent data that Zitadel keeps at the system level. With --instance, it covers the data of a single instance, which is the unit that holds organizations, users, projects and applications. Choose the scope deliberately: a system-only run on an installation with active tenants will not reproduce the tenant data your customers depend on, and a per-instance plan needs one pass per instance in scope. Inventory your instances and system-level data before the first run, and record the scope used for each pass so later runs repeat it exactly.

Repeat runs are how the destination catches up to a source that keeps changing. Run the mirror again as often as your change window allows, so each pass copies only what has changed since the last one, and the final pass happens shortly before the planned cutover while writes are paused or minimized. Then run zitadel mirror verify against both databases to report differences, and treat any reported difference as a blocker until it is explained. Ask your team to define in advance who signs off on a clean verify result and what the rollback path is if the cutover must be reversed. The command reports differences but does not decide your cutover window, which remains your decision.

How source, mirror and target fit during the move

The move starts with a running Zitadel instance backed by CockroachDB, which stays the system of record until cutover. An empty PostgreSQL target is prepared with zitadel init and zitadel setup --for-mirror, then zitadel mirror copies data into it at system or instance scope, and repeated runs bring the target up to date. Before any cutover decision, zitadel mirror verify reports differences between source and target, so the team knows whether to switch traffic or return to CockroachDB.

Phases from source database through mirror verification to cutover or return.

The migration sequence from first mirror run to cutover

This sequence moves a self-hosted Zitadel installation from CockroachDB to an empty PostgreSQL target while the source stays live, then switches traffic only after verification and a validated login path. Each step closes with a check so the team knows when it can move on and what it can roll back to.

  1. Confirm versions and support windows

    Before any data moves, confirm the Zitadel release you run and the PostgreSQL major version you plan to target. Zitadel supports PostgreSQL 14 through 18, and the PostgreSQL versioning policy lists end-of-support dates for each major version, so choose a target that will still receive security fixes through your planned operating period. Record the chosen versions in the change record. The check is a written sign-off from the platform owner that the source, Zitadel release and target database versions are all in supported ranges. Rollback point: nothing has changed yet, so the decision can be revised freely.

  2. Provision the empty PostgreSQL target

    Your database team, or DeployOpen under a written scope, provisions a new PostgreSQL instance that is empty, with the agreed high availability design, backups, TLS and network access limited to the Zitadel workloads. Create the database and role that Zitadel will use, and confirm that connection pooling, if used, is configured for the target. The check is a successful test connection from the Zitadel runtime network and a completed backup test on the new instance. Rollback point: the target is isolated and can be dropped without affecting production, because CockroachDB still serves all traffic.

  3. Initialize the target with init and setup for mirror

    Run the zitadel init step and then zitadel setup --for-mirror against the empty PostgreSQL target, using the same Zitadel release as the source so the schema matches. The mirror preparation creates the structures the copy needs, so do not load data into the target by hand. Keep the configuration for these commands in version control. The check is that both commands finish without errors and that the target contains the Zitadel schema with no application data. Rollback point: if setup fails, drop and recreate the empty target and rerun the commands, since the source is untouched.

  4. Run the first mirror with the chosen scope

    Run the zitadel mirror command from the source CockroachDB to the prepared PostgreSQL destination, choosing --system or --instance scope based on the decision made during planning. System scope covers system-level data across the installation, while instance scope limits the copy to one instance. Capture the command output and the scope flag in the change record. The check is that the mirror run exits cleanly and the log shows the copy completed for the selected scope. Rollback point: the destination can be reinitialized from step three, and the source continues serving production throughout.

  5. Repeat mirror runs until changes are small

    Because users keep signing in and changing data during the copy, run the mirror again on a schedule the team agrees, so each pass moves only recent changes. Track how long each run takes and how much it changes in the logs, and confirm with the vendor documentation how repeat runs handle deleted records and schema differences for your release. The check is a pattern of repeat runs that shrinks to a size the team can absorb inside a planned cutover window. Rollback point: any repeat run can be rerun, and the CockroachDB source remains authoritative until cutover.

  6. Verify the mirror and resolve differences

    Run zitadel mirror verify against the source and destination and read every reported difference. Decide for each one whether it is expected timing, a known transient, or a defect that needs a fix and a new mirror run. Do not accept a verification report with unexplained differences in identity or authorization data. The check is a verify result that the platform owner and security reviewer both sign, with each remaining difference documented. Rollback point: if differences cannot be resolved, keep CockroachDB as the live database and rerun the mirror after the cause is fixed.

  7. Schedule cutover and switch configuration

    Agree a cutover window with application owners, identity administrators and the support team, and announce it with the expected impact on sign-in. During the window, stop writes to the source, run a final mirror and verify pass, then update the Zitadel database configuration to point at PostgreSQL and restart the workloads in the order your deployment requires. The check is that all Zitadel pods or processes start, health probes pass and the database connection uses the new target. Rollback point: restore the previous configuration pointing at CockroachDB and restart, while the source still holds the last consistent state.

  8. Validate logins, tokens and keep CockroachDB as rollback

    After cutover, test representative sign-in flows for each identity provider and client type, including authorization code, token refresh, logout and any service account used for automation. Confirm that tokens are issued and accepted by relying parties and that user administration works in the console. Keep the CockroachDB source intact and read-only for an agreed period so the rollback path stays open, then decommission it under a documented retention decision. The check is a signed validation record and a dated decommission decision. Rollback point: the CockroachDB source with the pre-cutover configuration remains available until the agreed period ends.

Choosing system or instance scope for the mirror

System scope mirrors the installation-wide data that sits above individual instances. Choose it when you want the destination PostgreSQL database to hold the whole installation, including the system-level records that every instance depends on. The destination must be prepared with zitadel init and zitadel setup --for-mirror before the copy starts, so the schema and system tables already exist when data arrives.

  • Scope of the copy: all installation-level data is moved, not only the records belonging to one instance.
  • Preparation: the target database must be empty and initialized with the documented init and setup steps before the first run.
  • Verification: zitadel mirror verify compares the whole installation, so differences in any instance will surface in one report.
  • Cutover: the cutover applies to the whole installation at once, which simplifies the sequence but widens the window that must be planned.
  • Repeat runs: confirm how repeat runs treat already-copied data before you schedule them.

Before choosing this scope, confirm with the Zitadel mirror documentation which system-level records are included and whether any must be handled separately.

What makes a CockroachDB to PostgreSQL move take longer

This table lists the factors that most often extend a Zitadel move from CockroachDB to PostgreSQL, and what each one adds to the work. Read each row as a question to answer about your own installation before you commit to a cutover window. The main takeaway is that instance count, custom code reading the database, and the number of verification cycles usually matter more than raw data volume.

DriverWhy it changes effortHow to keep it down
Instances and organizationsEach instance is mirrored with its own scope decision, and more instances mean more verification runs and more sign-off.Inventory every instance and organization first, then group them by mirror scope so the plan is written once.
Data volumeLarger databases lengthen the copy and every repeat run, and they widen the window in which the source keeps changing.Measure the current size and plan the copy window with the team that owns the source cluster.
Custom Actions or integrations reading the databaseAny code that queries Zitadel tables directly must be found, tested against PostgreSQL, and repointed before cutover.List all direct database readers and confirm each one works with the PostgreSQL target in staging.
PgBouncer or connection poolingPooling in front of PostgreSQL changes connection behavior, so pool settings need testing under load before go-live.Decide on the pooler early and test the Zitadel connection settings with it in a non-production environment.
High availability design on PostgreSQLReplication, failover tooling and read-only standbys each need configuration and failover testing, and PostgreSQL does not detect primary failure on its own.Choose the HA pattern and external failover tooling before the mirror starts, so the target is production-ready at cutover.
Backup and point-in-time recoveryRecovery requirements dictate archiving setup and restore tests, which must be proven on the new target before it holds live identity data.Confirm the recovery objectives with the owner and run a restore test on the PostgreSQL target before cutover.
Verification cycles before cutoverEach run of mirror verify that reports differences adds a copy, a fix and another check, so unexpected differences extend the schedule.Plan for repeat mirror runs and verify after each one, and agree the acceptance criteria in writing before the first run.

Questions teams ask before moving Zitadel to PostgreSQL

How long does a move from CockroachDB to PostgreSQL take?

No duration is fixed by the Zitadel documentation, so the honest answer depends on the data volume, the number of instances in scope and how many repeat runs your change window allows. The work has distinct phases: provisioning an empty PostgreSQL target, running zitadel init and zitadel setup --for-mirror, copying data with zitadel mirror, running mirror verify, and rehearsing cutover. Ask any partner for a phase-by-phase plan tied to your environment, your data size and your test windows, and for the criteria that end each phase. Treat any single number offered without that breakdown as a guess.

Can our own team do this migration without a partner?

Yes, if your engineers can operate Kubernetes or Docker Compose, manage PostgreSQL 14 through 18 and read the mirror documentation closely. The work requires database administration, secrets handling, network access between the source and target, and a tested cutover runbook. Teams that lack recent PostgreSQL operations experience, or that cannot rehearse against a copy of production, often choose a fixed-scope engagement for the planning, rehearsal and verification steps. Weigh your staff's time against the risk of a failed cutover.

What do our staff and environments need to provide?

Plan for access to the running CockroachDB cluster, a PostgreSQL server within a supported major version, a staging Zitadel environment that matches production, and named owners for DNS, TLS and secrets. Your team also needs a change window, a place to run the zitadel mirror command, and someone who can approve the cutover decision. Confirm the exact network paths, credentials and firewall rules with your platform team before the rehearsal, because they are the most common source of delay. Check the Zitadel self-hosting documentation for the version you run.

Does cutover to PostgreSQL require downtime?

Plan for a write freeze on the source during the final sync, so the destination matches the last committed state before Zitadel switches. How long that freeze lasts depends on how far the data has drifted and how quickly mirror verify passes, which you should measure during rehearsal rather than assume. The PostgreSQL documentation describes logical replication as a way to reduce downtime for database major upgrades, but Zitadel's mirror flow is a separate process, so confirm with the Zitadel mirror documentation whether your version supports the final sync pattern you need.

What happens if mirror verify reports differences?

Do not cut over while differences remain unexplained. The zitadel mirror verify command reports differences between source and destination, so the first step is to read the report and classify each difference as expected drift during live writes or a real gap. Rerun the mirror for the affected scope, using the repeat-run behavior documented for the command, and verify again. If differences persist, stop, review the scope (system or instance), and check connectivity, permissions and schema preparation on the target. Record each resolution in the cutover evidence.

Can we roll back to CockroachDB after cutover?

Rollback depends on whether writes have landed only on PostgreSQL after cutover. Before you cut over, decide how long the CockroachDB cluster stays intact and running, who can authorize a switch back, and how you would replay or reconcile any writes made on the new database. Keep the source read-only or retained until acceptance testing completes, and rehearse the reverse path in staging. Confirm with Zitadel which data changes are safe to reverse, because a rollback plan that was never tested is not a plan.

What does a fixed-scope quote for this migration cover?

A fixed-scope quote follows from a written scope that DeployOpen agrees with you before work starts, so the quote should list the instances and environments in scope, the PostgreSQL target and its configuration, the mirror and verification runs, the rehearsal and cutover support, and the documented handover. Ask whether the quote includes staging rehearsals, production cutover support, rollback testing and post-cutover checks, and what is excluded, such as application changes or Zitadel version upgrades. Ask for deliverables and acceptance criteria in writing. DeployOpen does not publish a price list, so the quote is the basis for cost.

How DeployOpen scopes, delivers and supports the Zitadel database migration

DeployOpen plans the move of a self-hosted Zitadel installation from CockroachDB to PostgreSQL as a written, fixed-scope engagement inside your own infrastructure. The work covers target preparation, mirror runs, verification and cutover, with documentation your operations team keeps after the project ends.

How we scope

  • Inventory the current CockroachDB deployment, Zitadel version, instance count and scope (system or instance) before any target is built
  • Agree in writing which PostgreSQL target, hosting model and network path the mirror runs against
  • Define the cutover window, rollback conditions and the sign-off criteria for mirror verify results

How we build

  • Prepare an empty PostgreSQL target that is supported for your Zitadel release, using zitadel init and setup --for-mirror
  • Run zitadel mirror with the agreed scope, then repeat runs to keep the target current until cutover
  • Run zitadel mirror verify, investigate every reported difference and retest after each fix

How we hand over

  • Deliver a runbook covering the mirror commands, repeat-run sequence, verification output and cutover steps
  • Document the PostgreSQL configuration, connection settings and access controls set for the new database
  • Walk your operations and security teams through the evidence trail for the migration and the rollback plan

How we support

  • Engagements are fixed-scope, so changes after the written scope are agreed as a separate change
  • Post-cutover monitoring and follow-up questions can be covered by a retainer if your team wants ongoing help
  • Confirm with us which PostgreSQL support window and Zitadel release your installation will use after cutover

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.