Overview
You build your data model on a development instance, and at some point that work has to reach staging and production. Environment Sync makes that a git workflow: the Directus CLI (directus-cli, or its short alias d6s) writes an instance's Schema and Configuration to JSON sync files you commit, then applies those files to any instance you point it at.
d6s sync pull --from staging # write the instance's Schema + Configuration to sync files
d6s sync diff --to production # preview what pushing the sync files would change
d6s sync push --to production # apply them
Because the sync files live in your repository, you can review changes in pull requests, promote them through git history, and roll them back with a revert. (d6s sync on its own runs a small interactive wizard that pulls and pushes in one pass.)
The CLI is built to be safe to point at production: diff never applies anything, deletions always require their own explicit consent, and the CLI asks you to resolve records that match more than one target record. It never guesses. How It Works covers the full safety model.
What syncs
- Schema: every collection, field, and relation, including custom fields on system collections.
- Configuration: roles, policies, access, permissions, flows, operations, dashboards, panels, settings, media-library folders, and custom Data Studio translation strings.
- Opt-in: user accounts, with every secret field stripped.
Records in your own collections are content, and Environment Sync does not sync them. It moves the shape of a project and its configuration, not its content.
Before you start
- Both instances must run the same Directus version, patch release included. The server refuses cross-version schema changes because some patch releases change the schema format. Align your environments before you sync them.
- An admin credential for each instance. The schema and configuration endpoints the CLI uses are admin-only. A static token from an admin user is the usual choice.
- A git repository. The sync files are designed for review and versioning. Any repository works; many teams use the one that already holds their Directus deployment configuration.
Where to go
Quickstart
Run the full pull, diff, push loop against two throwaway instances and see every command's output.
How It Works
The mental model: sync files as the source of truth, record identity, push phases, and the safety rules.
Common Workflows
Promote changes, ship only what's ready, adopt sync on an existing project, roll back, recover from drift.
CI & Automation
Post the production diff on pull requests and push on merge, with tokens and JSON reports.
Get once-a-month release notes & real‑world code tips...no fluff. 🐰