TIP
Original: View on authzed.com 中文版: 查看中文版
Migrating from SpiceDB to SpiceDB
This documentation covers migrating data between SpiceDB instances with minimal downtime, such as when moving to AuthZed Cloud.
Important Notes
This guide addresses SpiceDB-to-SpiceDB data migration only. For schema migrations of underlying datastores (Postgres, CockroachDB), or SpiceDB schema changes, refer to separate documentation sections.
WARNING
Direct database-level migration using tools like pg_dump/pg_restore is not recommended and can break SpiceDB MVCC. When migrating between different datastore types (e.g., Postgres to CockroachDB), you must use SpiceDB APIs (exportBulk/importBulk or zed backup).
Prerequisites
- zed CLI tool
Migration Options
Option 1: With Write Downtime Migration
A straightforward approach incurring write downtime (not read downtime) during backup and restore.
Steps:
- Spin up your new SpiceDB instance
- Stop writes to the old SpiceDB
- Run
zed backup create <filename>against the old SpiceDB - Run
zed backup restore <filename>against the new SpiceDB using the generated backup file - Switch reads to the new SpiceDB
- Start writing to the new SpiceDB
Option 2: With Near Zero Write Downtime Migration
A more complex approach minimizing write downtime through continuous synchronization.
Steps:
- Spin up your new SpiceDB instance
- Run
zed backup create <filename>against the old SpiceDB - Run
zed backup restore <filename>against the new SpiceDB - Run
zed backup parse-revision <filename>to obtain the zed token pointing to the backup revision - Using your chosen SpiceDB client library, create a script calling the Watch API continuously, writing each relationship change from the old SpiceDB to the new instance. In the initial API call, provide the zed token as the
optional_start_cursorin theWatchRequestobject. Run until ready to stop old writes. - Stop writes to the old SpiceDB
- Wait for the script to receive no more changes (minimal write downtime occurs here)
- Switch reads and writes to the new SpiceDB