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 files you commit, and applies those files to any instance you point it at.
d6s sync pull --from staging # write the instance's schema + configuration to files
d6s sync diff --to production # preview what pushing those files would change
d6s sync push --to production # apply them
Because the files live in your repository, your normal review workflow applies: schema changes show up in pull requests, environments are brought up to date through git history, and a bad change is a revert away from being found. (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 a record that could match more than one target record is asked about, never guessed. 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, and media-library folders.
- Opt-in: user accounts (with every secret column stripped) and translation strings.
Your own collections' content, the rows in the tables you create, is not synced. Environment Sync moves the shape of a project and its configuration, not its data.
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 files the CLI writes are only useful committed. 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: 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. 🐰