Skip to content
View as Markdown

Cloning Data ​

Cloning copies the live data of a deployed application from one workspace into another, much as branching a database in other services gives you an isolated copy to work against. It clones the TailorDB data of every namespace in the application's subgraph, so the target workspace ends up holding the same records as the original. File contents and IdP users can be included as well.

A clone is useful when you need production-shaped data outside production:

  • Rehearse a pending schema migration against a realistic dataset before deploying it
  • Seed a staging or QA workspace with a snapshot of real records
  • Reproduce an issue in an isolated workspace without touching the source

What gets copied ​

A clone copies data, not configuration. The target application and its schema must already exist (see Prerequisites); the clone fills that empty application with records.

DataCopiedOption
TailorDB recordsAlwaysNone
TailorDB file contentsOnly when requested--copy-files
IdP users (with passwords)Only when requested--copy-idp-users

By default a clone copies TailorDB records only. File field contents and IdP users are opt-in, so with the defaults, file fields in the cloned records have no downloadable content and the target has no IdP users.

The following are not part of a clone. The target application already carries its own:

  • Application manifest, subgraphs, and API endpoint configuration
  • Resolvers, Executors, Functions, and Workflows
  • Secret Manager values and auth connection credentials

Prerequisites ​

You need the editor role or higher on both the source and target workspaces. Beyond that, the platform rejects a clone with a failed precondition unless all of the following hold. Prepare the target first:

  • Same region. The source and target workspaces must be in the same region.
  • Same namespaces. The target application must contain the same TailorDB namespaces as the source.
  • Matching schema. The target's TailorDB schema must match the source's, so deploy the same version of the application to the target before cloning.
  • Empty target. The target must be empty for every namespace and copy type in scope. TailorDB tables must hold no records, and when --copy-files or --copy-idp-users is set, there must be no files or IdP users either.

Cloning data ​

Use tailor data clone with the source and target workspace IDs. The application name must be the same in both workspaces; it defaults to the name in your tailor.config.ts.

bash
tailor data clone \
  --from <source-workspace-id> \
  --to   <target-workspace-id> \
  --name my-app

The command prints an operation ID, then waits until the clone finishes before returning. The clone runs on the platform, so stopping the command with Ctrl+C does not stop the clone; it keeps running.

Including files and IdP users ​

Add the opt-in flags to extend the clone beyond records:

bash
tailor data clone \
  --from <source-workspace-id> \
  --to   <target-workspace-id> \
  --name my-app \
  --copy-files \
  --copy-idp-users

Cloned IdP users keep their passwords

--copy-idp-users copies users together with their passwords, carried over to the target as-is. Anyone who knows a user's password on the source can sign in as that user on the clone. Treat a workspace cloned with this flag with the same care as the source, and avoid it for environments with a wider audience than production.

Tracking the operation ​

A clone is asynchronous. tailor data clone waits for it by default, but you can detach and poll instead, which is useful in scripts or for long-running clones.

Pass --no-wait to start the clone and exit immediately with the operation ID:

bash
tailor data clone --from <source-workspace-id> --to <target-workspace-id> --name my-app --no-wait

Then check or wait on that operation with tailor data operation get:

bash
# Print the current status once
tailor data operation get --from <source-workspace-id> --to <target-workspace-id> --operation-id <operation-id>

# Block until the clone completes or fails
tailor data operation get --from <source-workspace-id> --to <target-workspace-id> --operation-id <operation-id> --wait

An operation moves through pending, processing, and then either completed or failed. Under --json, tailor data clone reports status: "completed" once the clone finishes, or status: "started" when you pass --no-wait.

Using clone for migration testing ​

To rehearse a schema migration against real data, you do not have to run data clone by hand. TailorDB migration testing can clone the source records for you:

bash
tailor tailordb migration test --data clone

This provisions an isolated workspace, clones the source TailorDB records into it, runs the real migration phases, and tears the workspace down afterward unless you pass --keep. Clone mode here copies TailorDB records only; it does not copy file contents or IdP users.

  • Data Commands - Full reference for tailor data clone and tailor data operation
  • TailorDB Migration - Rehearse migrations with cloned data
  • File Type - The file fields that --copy-files includes
  • Auth - The IdP whose users --copy-idp-users includes