---
title: "clone - Xata"
description: "Commands for managing database streaming (logical replication) operations"
source: "https://xata.io/docs/cli/clone"
---

Skip to main content

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.

```
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]
```

​

\--source-url

string

The source URL of the database to clone

​

\--config

string

.env or .yaml config file to use with pgstream if any

​

\--log-level

string

Log level for the application. One of trace, debug, info, warn, error, fatal, panic

​

\--dump-file

string

File where the pg_dump output will be written

​

\--postgres-url

string

Source postgres database to perform the snapshot from

​

\--profile

boolean

Whether to produce CPU and memory profile files, as well as exposing a /debug/pprof endpoint on localhost:6060

​

\--reset

boolean

Whether to reset the target before snapshotting (only for postgres target)

​

\--tables

string

List of tables to snapshot, in the format `<schema>.<table>`. If not specified, the schema `public` will be assumed. Wildcards are supported

​

\--target

string

Target type. One of postgres, opensearch, elasticsearch, kafka

​

\--target-url

string

Target URL

​

\--organization

string

Organization ID (default: "")

​

\--project

string

Project ID (default: "")

​

\--branch

string

Branch ID (default: "")

​

\--filter-tables

string

Tables to filter (default: _._)

​

\--validation-mode

string

Anonymization validation mode, strict implies that all tables and columns should be specified (strict|relaxed|prompt, default: prompt)

​

\--role

string

Postgres role to use for the clone

​

-h, --help

boolean

Print help information and exit

### ​config

Automatically configure the transformations for the clone command.

```
xata clone config [--source-url <url>] [--mode <mode>] [--validation-mode <mode>] [--organization <id>] [--project <id>] [--branch <id>] [-h|--help]
```

​

\--source-url

string

The source URL of the database to clone

​

\--mode

string

The assisting mode to help with the configuration generation (auto|prompt|web|ai, default: prompt)

​

\--validation-mode

string

Anonymization validation mode, strict implies that all tables and columns should be specified (strict|relaxed|prompt, default: prompt)

​

\--organization

string

Organization ID (default: "")

​

\--project

string

Project ID (default: "")

​

\--branch

string

Branch ID (default: "")

​

-h, --help

boolean

Print help information and exit

### ​stream

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

```
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]
```

​

\--source-url

string

required

The source URL of the database to stream from

​

\--config

string

.env or .yaml config file to use with pgstream if any

​

\--log-level

string

Log level for pgstream (trace|debug|info|warn|error|fatal|panic, default: info)

​

\--init

boolean

Whether to initialize pgstream before starting replication

​

\--profile

boolean

Whether to expose a /debug/pprof endpoint on localhost:6060

​

\--replication-slot

string

Name of the postgres replication slot for pgstream to connect to

​

\--reset

boolean

Whether to reset the target before snapshotting (only for postgres target)

​

\--snapshot-tables

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

​

\--source

string

Source type. One of postgres, kafka

​

\--target

string

Target type. One of postgres, opensearch, elasticsearch, kafka

​

\--target-url

string

Target URL

​

\--organization

string

Organization ID

​

\--project

string

Project ID

​

\--branch

string

Branch ID

​

\--filter-tables

string

Tables to filter (default: _._)

​

\--validation-mode

string

Anonymization validation mode, strict implies that all tables and columns should be specified (strict|relaxed|prompt, default: prompt)

​

\--role

string

Postgres role to use for streaming (it should have atleast REPLICATION privilege)

​

\--copy-roles

boolean

Copy roles, owners, and privileges to the target (default: false)

​

\--skip-ddl-tracking

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)

​

-h, --help

boolean

Print help information and exit

## ​Global Flags

​

-h, --help

boolean

Print help information and exit

​

\--json

boolean

Output in JSON format

Was this page helpful?

[Previous](/docs/cli/checkout)

[completions](/docs/cli/completions)

[Next](/docs/cli/completions)
