> ## Documentation Index
> Fetch the complete documentation index at: https://xata.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# clone

> Commands for managing database streaming (logical replication) operations

The `clone` command helps you create a copy of your Xata database or clone an external PostgreSQL database into Xata. It supports data anonymization and advanced configuration for complex migration scenarios.

## Subcommands

### start

Start performs a snapshot of the configured source Postgres database into the configured target.

```bash theme={null}
xata clone start [--source-url <url>] [--config <file>] [--log-level <level>] [--dump-file <file>] [--postgres-url <url>] [--profile] [--reset] [--tables <tables>] [--target <type>] [--target-url <url>] [--organization <id>] [--project <id>] [--branch <id>] [--filter-tables <tables>] [--validation-mode <mode>] [--role <role>] [-h|--help]
```

<ParamField path="--source-url" type="string">
  The source URL of the database to clone
</ParamField>

<ParamField path="--config" type="string">
  .env or .yaml config file to use with pgstream if any
</ParamField>

<ParamField path="--log-level" type="string">
  Log level for the application. One of trace, debug, info, warn, error, fatal, panic
</ParamField>

<ParamField path="--dump-file" type="string">
  File where the pg\_dump output will be written
</ParamField>

<ParamField path="--postgres-url" type="string">
  Source postgres database to perform the snapshot from
</ParamField>

<ParamField path="--profile" type="boolean">
  Whether to produce CPU and memory profile files, as well as exposing a /debug/pprof endpoint on localhost:6060
</ParamField>

<ParamField path="--reset" type="boolean">
  Whether to reset the target before snapshotting (only for postgres target)
</ParamField>

<ParamField path="--tables" type="string">
  List of tables to snapshot, in the format `<schema>.<table>`. If not specified, the schema `public` will be assumed. Wildcards are supported
</ParamField>

<ParamField path="--target" type="string">
  Target type. One of postgres, opensearch, elasticsearch, kafka
</ParamField>

<ParamField path="--target-url" type="string">
  Target URL
</ParamField>

<ParamField path="--organization" type="string">
  Organization ID (default: "")
</ParamField>

<ParamField path="--project" type="string">
  Project ID (default: "")
</ParamField>

<ParamField path="--branch" type="string">
  Branch ID (default: "")
</ParamField>

<ParamField path="--filter-tables" type="string">
  Tables to filter (default: *.*)
</ParamField>

<ParamField path="--validation-mode" type="string">
  Anonymization validation mode, strict implies that all tables and columns should be specified (strict|relaxed|prompt, default: prompt)
</ParamField>

<ParamField path="--role" type="string">
  Postgres role to use for the clone
</ParamField>

<ParamField path="-h, --help" type="boolean">
  Print help information and exit
</ParamField>

### config

Automatically configure the transformations for the clone command.

```bash theme={null}
xata clone config [--source-url <url>] [--mode <mode>] [--validation-mode <mode>] [--organization <id>] [--project <id>] [--branch <id>] [-h|--help]
```

<ParamField path="--source-url" type="string">
  The source URL of the database to clone
</ParamField>

<ParamField path="--mode" type="string">
  The assisting mode to help with the configuration generation (auto|prompt|web|ai, default: prompt)
</ParamField>

<ParamField path="--validation-mode" type="string">
  Anonymization validation mode, strict implies that all tables and columns should be specified (strict|relaxed|prompt, default: prompt)
</ParamField>

<ParamField path="--organization" type="string">
  Organization ID (default: "")
</ParamField>

<ParamField path="--project" type="string">
  Project ID (default: "")
</ParamField>

<ParamField path="--branch" type="string">
  Branch ID (default: "")
</ParamField>

<ParamField path="-h, --help" type="boolean">
  Print help information and exit
</ParamField>

### stream

Start a continuous data stream from the configured source to the configured target using Postgres's logical replication.

```bash theme={null}
xata clone stream --source-url <url> [--config <file>] [--log-level <level>] [--init] [--profile] [--replication-slot <name>] [--reset] [--snapshot-tables <tables>] [--source <type>] [--target <type>] [--target-url <url>] [--organization <id>] [--project <id>] [--branch <id>] [--filter-tables <tables>] [--validation-mode <mode>] [--role <role>] [--copy-roles] [--skip-ddl-tracking] [-h|--help]
```

<ParamField path="--source-url" type="string" required>
  The source URL of the database to stream from
</ParamField>

<ParamField path="--config" type="string">
  .env or .yaml config file to use with pgstream if any
</ParamField>

<ParamField path="--log-level" type="string">
  Log level for pgstream (trace|debug|info|warn|error|fatal|panic, default: info)
</ParamField>

<ParamField path="--init" type="boolean">
  Whether to initialize pgstream before starting replication
</ParamField>

<ParamField path="--profile" type="boolean">
  Whether to expose a /debug/pprof endpoint on localhost:6060
</ParamField>

<ParamField path="--replication-slot" type="string">
  Name of the postgres replication slot for pgstream to connect to
</ParamField>

<ParamField path="--reset" type="boolean">
  Whether to reset the target before snapshotting (only for postgres target)
</ParamField>

<ParamField path="--snapshot-tables" type="string">
  List of tables to snapshot if initial snapshot is required, in the format `<schema>.<table>`. If not specified, the schema `public` will be assumed. Wildcards are supported
</ParamField>

<ParamField path="--source" type="string">
  Source type. One of postgres, kafka
</ParamField>

<ParamField path="--target" type="string">
  Target type. One of postgres, opensearch, elasticsearch, kafka
</ParamField>

<ParamField path="--target-url" type="string">
  Target URL
</ParamField>

<ParamField path="--organization" type="string">
  Organization ID
</ParamField>

<ParamField path="--project" type="string">
  Project ID
</ParamField>

<ParamField path="--branch" type="string">
  Branch ID
</ParamField>

<ParamField path="--filter-tables" type="string">
  Tables to filter (default: *.*)
</ParamField>

<ParamField path="--validation-mode" type="string">
  Anonymization validation mode, strict implies that all tables and columns should be specified (strict|relaxed|prompt, default: prompt)
</ParamField>

<ParamField path="--role" type="string">
  Postgres role to use for streaming (it should have atleast REPLICATION privilege)
</ParamField>

<ParamField path="--copy-roles" type="boolean">
  Copy roles, owners, and privileges to the target (default: false)
</ParamField>

<ParamField path="--skip-ddl-tracking" type="boolean">
  Skip DDL tracking during streaming. Useful for managed PostgreSQL services that do not support superuser access required for event triggers. Requires --replication-slot flag to be set with a pre-created replication slot on the source database (default: false)
</ParamField>

<ParamField path="-h, --help" type="boolean">
  Print help information and exit
</ParamField>

## Global Flags

<ParamField path="-h, --help" type="boolean">
  Print help information and exit
</ParamField>

<ParamField path="--json" type="boolean">
  Output in JSON format
</ParamField>
