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

# MOLT Fetch Commands and Flags

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

This page lists the <InternalLink path="molt-fetch">MOLT Fetch</InternalLink> commands and the flags that you can use to configure a MOLT Fetch command execution.

## Commands

| Command | Usage                                                                                          |
| ------- | ---------------------------------------------------------------------------------------------- |
| `fetch` | Start the fetch task. This loads data from a source database to a target CockroachDB database. |

### Subcommands

| Command       | Usage                                                                                                           |
| ------------- | --------------------------------------------------------------------------------------------------------------- |
| `tokens list` | List active <InternalLink path="molt-fetch#list-active-continuation-tokens">continuation tokens</InternalLink>. |

## Flags

### Global flags

| Flag                                                                                                             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="source" /> `--source`                                                                                     | (Required) Connection string used to connect to the Oracle PDB (in a CDB/PDB architecture) or to a standalone database (non‑CDB). For details, refer to <InternalLink path="molt-fetch#specify-source-and-target-databases">Source and target databases</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <a id="source-cdb" /> `--source-cdb`                                                                             | Connection string for the Oracle container database (CDB) when using a multitenant (CDB/PDB) architecture. Omit this flag on a non‑multitenant Oracle database. For details, refer to <InternalLink path="molt-fetch#specify-source-and-target-databases">Source and target databases</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                                             |
| <a id="target" /> `--target`                                                                                     | (Required) Connection string for the target database. For details, refer to <InternalLink path="molt-fetch#specify-source-and-target-databases">Source and target databases</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| <a id="allow-tls-mode-disable" /> `--allow-tls-mode-disable`                                                     | Allow insecure connections to databases. Secure SSL/TLS connections should be used by default. This should be enabled **only** if secure SSL/TLS connections to the source or target database are not possible.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| <a id="assume-role" /> `--assume-role`                                                                           | Service account to use for assume role authentication. `--use-implicit-auth` must be included. For example, `--assume-role='user-test@cluster-ephemeral.iam.gserviceaccount.com' --use-implicit-auth`. For details, refer to <InternalLink version="stable" path="cloud-storage-authentication">Cloud Storage Authentication</InternalLink>.                                                                                                                                                                                                                                                                                                                                                      |
| <a id="bucket-path" /> `--bucket-path`                                                                           | The path within the <InternalLink path="molt-fetch#bucket-path">cloud storage</InternalLink> bucket where intermediate files are written (e.g., `'s3://bucket/path'` or `'gs://bucket/path'`). Only the URL path is used; query parameters (e.g., credentials) are ignored. To pass in query parameters, use the appropriate flags: `--assume-role`, `--import-region`, `--use-implicit-auth`.                                                                                                                                                                                                                                                                                                    |
| <a id="case-sensitive" /> `--case-sensitive`                                                                     | Toggle case sensitivity when comparing table and column names on the source and target. To disable case sensitivity, set `--case-sensitive=false`. If `=` is **not** included (e.g., `--case-sensitive false`), the flag is interpreted as `--case-sensitive` (i.e., `--case-sensitive=true`).<br /><br />**Default:** `false`                                                                                                                                                                                                                                                                                                                                                                    |
| <a id="cleanup" /> `--cleanup`                                                                                   | Whether to delete intermediate files after moving data using <InternalLink path="molt-fetch#define-intermediate-storage">cloud or local storage</InternalLink>. **Note:** Cleanup does not occur on <InternalLink path="molt-fetch#continue-molt-fetch-after-interruption">continuation</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                                           |
| <a id="compression" /> `--compression`                                                                           | Compression method for data when using <InternalLink path="molt-fetch#import-into-vs-copy-from">`IMPORT INTO`</InternalLink> (`gzip`/`none`).<br /><br />**Default:** `gzip`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| <a id="continuation-file-name" /> `--continuation-file-name`                                                     | Restart fetch at the specified filename if the task encounters an error. `--fetch-id` must be specified. For details, see <InternalLink path="molt-fetch#continue-molt-fetch-after-interruption">Fetch continuation</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| <a id="continuation-token" /> `--continuation-token`                                                             | Restart fetch at a specific table, using the specified continuation token, if the task encounters an error. `--fetch-id` must be specified. For details, see <InternalLink path="molt-fetch#continue-molt-fetch-after-interruption">Fetch continuation</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                                                                            |
| <a id="crdb-pts-duration" /> `--crdb-pts-duration`                                                               | The duration for which each timestamp used in data export from a CockroachDB source is protected from garbage collection. This ensures that the data snapshot remains consistent. For example, if set to `24h`, each timestamp is protected for 24 hours from the initiation of the export job. This duration is extended at regular intervals specified in `--crdb-pts-refresh-interval`.<br /><br />**Default:** `24h0m0s`                                                                                                                                                                                                                                                                      |
| <a id="crdb-pts-refresh-interval" /> `--crdb-pts-refresh-interval`                                               | The frequency at which the protected timestamp's validity is extended. This interval maintains protection of the data snapshot until data export from a CockroachDB source is completed. For example, if set to `10m`, the protected timestamp's expiration will be extended by the duration specified in `--crdb-pts-duration` (e.g., `24h`) every 10 minutes while export is not complete. <br /><br />**Default:** `10m0s`                                                                                                                                                                                                                                                                     |
| <a id="direct-copy" /> `--direct-copy`                                                                           | Enables <InternalLink path="molt-fetch#direct-copy">direct copy</InternalLink>, which copies data directly from source to target without using an intermediate store.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| <a id="export-concurrency" /> `--export-concurrency`                                                             | Number of shards to export at a time per table, each on a dedicated thread. This controls how many shards are created for each individual table during the <InternalLink path="molt-fetch#data-export-phase">data export phase</InternalLink> and is distinct from `--table-concurrency`, which controls how many tables are processed simultaneously. The total number of concurrent threads is the product of `--export-concurrency` and `--table-concurrency`. Tables can be sharded with a range-based or stats-based mechanism. For details, refer to <InternalLink path="molt-fetch#shard-tables-for-concurrent-export">Table sharding</InternalLink>.<br /><br />**Default:** `4`          |
| <a id="export-retry-max-attempts" /> `--export-retry-max-attempts`                                               | Maximum number of retry attempts for source export queries when connection failures occur. Only supported for PostgreSQL and CockroachDB sources.<br /><br />**Default:** `3`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| <a id="export-retry-max-duration" /> `--export-retry-max-duration`                                               | Maximum total duration for retrying source export queries. If `0`, no time limit is enforced. Only supported for PostgreSQL and CockroachDB sources.<br /><br />**Default:** `5m0s`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| <a id="filter-path" /> `--filter-path`                                                                           | Path to a JSON file defining row-level filters for the <InternalLink path="molt-fetch#data-import-phase">data import phase</InternalLink>. Refer to <InternalLink path="molt-fetch#select-data-to-migrate">Selective data movement</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| <a id="fetch-id" /> `--fetch-id`                                                                                 | Restart fetch task corresponding to the specified ID. If `--continuation-file-name` or `--continuation-token` are not specified, fetch restarts for all failed tables.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| <a id="flush-rows" /> `--flush-rows`                                                                             | Number of rows before the source data is flushed to intermediate files. **Note:** If `--flush-size` is also specified, the fetch behavior is based on the flag whose criterion is met first.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| <a id="flush-size" /> `--flush-size`                                                                             | Size (in bytes) before the source data is flushed to intermediate files. **Note:** If `--flush-rows` is also specified, the fetch behavior is based on the flag whose criterion is met first.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| <a id="ignore-replication-check" /> `--ignore-replication-check`                                                 | Skip querying for replication checkpoints such as `pg_current_wal_insert_lsn()` on PostgreSQL, `gtid_executed` on MySQL, and `CURRENT_SCN` on Oracle. This option is intended for use during bulk load migrations or when doing a one-time data export from a read replica.                                                                                                                                                                                                                                                                                                                                                                                                                       |
| <a id="import-batch-size" /> `--import-batch-size`                                                               | The number of files to be imported at a time to the target database during the <InternalLink path="molt-fetch#data-import-phase">data import phase</InternalLink>. This applies only when using <InternalLink path="molt-fetch#import-into-vs-copy-from">`IMPORT INTO`</InternalLink> for data movement. **Note:** Increasing this value can improve the performance of full-scan queries on the target database shortly after fetch completes, but very high values are not recommended. If any individual file in the import batch fails, you must <InternalLink path="molt-fetch#continue-molt-fetch-after-interruption">retry</InternalLink> the entire batch.<br /><br />**Default:** `1000` |
| <a id="import-region" /> `--import-region`                                                                       | The region of the <InternalLink path="molt-fetch#bucket-path">cloud storage</InternalLink> bucket. This applies only to <InternalLink path="molt-fetch#bucket-path">Amazon S3 buckets</InternalLink>. Set this flag only if you need to specify an `AWS_REGION` explicitly when using <InternalLink path="molt-fetch#import-into-vs-copy-from">`IMPORT INTO`</InternalLink> for data movement. For example, `--import-region=ap-south-1`.                                                                                                                                                                                                                                                         |
| <a id="local-path" /> `--local-path`                                                                             | The path within the <InternalLink path="molt-fetch#local-path">local file server</InternalLink> where intermediate files are written (e.g., `data/migration/cockroach`). `--local-path-listen-addr` must be specified.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| <a id="local-path-crdb-access-addr" /> `--local-path-crdb-access-addr`                                           | Address of a <InternalLink path="molt-fetch#local-path">local file server</InternalLink> that is **publicly accessible**. This flag is only necessary if CockroachDB cannot reach the local address specified with `--local-path-listen-addr` (e.g., when moving data to a CockroachDB Cloud deployment). `--local-path` and `--local-path-listen-addr` must be specified.<br /><br />**Default:** Value of `--local-path-listen-addr`.                                                                                                                                                                                                                                                           |
| <a id="local-path-listen-addr" /> `--local-path-listen-addr`                                                     | Write intermediate files to a <InternalLink path="molt-fetch#local-path">local file server</InternalLink> at the specified address (e.g., `'localhost:3000'`). `--local-path` must be specified.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| <a id="log-file" /> `--log-file`                                                                                 | Write messages to the specified log filename. If no filename is provided, messages write to `fetch-{datetime}.log`. If `"stdout"` is provided, messages write to `stdout`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| <a id="logging" /> `--logging`                                                                                   | Level at which to log messages (`trace`/`debug`/`info`/`warn`/`error`/`fatal`/`panic`).<br /><br />**Default:** `info`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| <a id="metrics-listen-addr" /> `--metrics-listen-addr`                                                           | Address of the Prometheus metrics endpoint, which has the path `{address}/metrics`. For details on important metrics to monitor, refer to <InternalLink path="molt-fetch-monitoring">Monitoring</InternalLink>.<br /><br />**Default:** `'127.0.0.1:3030'`                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| <a id="mode" /> `--mode`                                                                                         | Configure the MOLT Fetch behavior: `data-load`, `export-only`, or `import-only`. For details, refer to <InternalLink path="molt-fetch#define-fetch-mode">Fetch mode</InternalLink>.<br /><br />**Default:** `data-load`                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <a id="non-interactive" /> `--non-interactive`                                                                   | Run the fetch task without interactive prompts. This is recommended **only** when running `molt fetch` in an automated process (i.e., a job or continuous integration).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <a id="opt-out-telemetry" /> `--opt-out-telemetry`                                                               | Suppress MOLT telemetry-event logging, which is enabled by default.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| <a id="pglogical-replication-slot-name" /> `--pglogical-replication-slot-name`                                   | Name of a PostgreSQL replication slot that will be created before taking a snapshot of data. Must match the slot name specified with `--slotName` in the <InternalLink path="molt-replicator#replication-checkpoints">MOLT Replicator command</InternalLink>. For details, refer to <InternalLink path="molt-fetch#initial-bulk-load-before-replication">Initial bulk load (before replication)</InternalLink>.                                                                                                                                                                                                                                                                                   |
| <a id="pglogical-publication-and-slot-drop-and-recreate" /> `--pglogical-publication-and-slot-drop-and-recreate` | Drop the PostgreSQL publication and replication slot if they exist, then recreate them. Creates a publication named `molt_fetch` and the replication slot specified with `--pglogical-replication-slot-name`. For details, refer to <InternalLink path="molt-fetch#initial-bulk-load-before-replication">Initial bulk load (before replication)</InternalLink>.<br /><br />**Default:** `false`                                                                                                                                                                                                                                                                                                   |
| <a id="pprof-listen-addr" /> `--pprof-listen-addr`                                                               | Address of the pprof endpoint.<br /><br />**Default:** `'127.0.0.1:3031'`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| <a id="row-batch-size" /> `--row-batch-size`                                                                     | Number of rows per shard to export at a time. For details on sharding, refer to <InternalLink path="molt-fetch#shard-tables-for-concurrent-export">Table sharding</InternalLink>. See also <InternalLink path="molt-fetch-best-practices">Best practices</InternalLink>.<br /><br />**Default:** `100000`                                                                                                                                                                                                                                                                                                                                                                                         |
| <a id="schema-filter" /> `--schema-filter`                                                                       | Move schemas that match a specified [regular expression](https://wikipedia.org/wiki/Regular_expression).<br /><br />**Default:** `'.*'`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <a id="skip-pk-check" /> `--skip-pk-check`                                                                       | Skip primary-key matching to allow data load when source or target tables have missing or mismatched primary keys. Disables sharding and bypasses `--export-concurrency` and `--row-batch-size` settings. Refer to <InternalLink path="molt-fetch#skip-primary-key-matching">Skip primary key matching</InternalLink>.<br /><br />**Default:** `false`                                                                                                                                                                                                                                                                                                                                            |
| <a id="table-concurrency" /> `--table-concurrency`                                                               | Number of tables to export at a time. The number of concurrent threads is the product of `--export-concurrency` and `--table-concurrency`.<br /><br />**Default:** `4`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| <a id="table-exclusion-filter" /> `--table-exclusion-filter`                                                     | Exclude tables that match a specified [POSIX regular expression](https://wikipedia.org/wiki/Regular_expression).<br /><br />This value **cannot** be set to `'.*'`, which would cause every table to be excluded. <br /><br />**Default:** Empty string                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <a id="table-filter" /> `--table-filter`                                                                         | Move tables that match a specified [POSIX regular expression](https://wikipedia.org/wiki/Regular_expression).<br /><br />**Default:** `'.*'`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| <a id="table-handling" /> `--table-handling`                                                                     | How tables are initialized on the target database (`none`/`drop-on-target-and-recreate`/`truncate-if-exists`). For details, see <InternalLink path="molt-fetch#handle-target-tables">Target table handling</InternalLink>.<br /><br />**Default:** `none`                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| <a id="transformations-file" /> `--transformations-file`                                                         | Path to a JSON file that defines transformations to be performed on the target schema during the fetch task. Refer to <InternalLink path="molt-fetch#define-transformations">Transformations</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| <a id="type-map-file" /> `--type-map-file`                                                                       | Path to a JSON file that contains explicit type mappings for automatic schema creation, when enabled with `--table-handling drop-on-target-and-recreate`. For details on the JSON format and valid type mappings, see <InternalLink path="molt-fetch#type-mapping">type mapping</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                                                   |
| <a id="use-console-writer" /> `--use-console-writer`                                                             | Use the console writer, which has cleaner log output but introduces more latency.<br /><br />**Default:** `false` (log as structured JSON)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| <a id="use-copy" /> `--use-copy`                                                                                 | Use <InternalLink path="molt-fetch#import-into-vs-copy-from">`COPY FROM`</InternalLink> to move data. This makes tables queryable during data load, but is slower than using `IMPORT INTO`. For details, refer to <InternalLink path="molt-fetch#import-into-vs-copy-from">Data movement</InternalLink>.                                                                                                                                                                                                                                                                                                                                                                                          |
| <a id="use-implicit-auth" /> `--use-implicit-auth`                                                               | Use <InternalLink version="stable" path="cloud-storage-authentication">implicit authentication</InternalLink> for <InternalLink path="molt-fetch#bucket-path">cloud storage</InternalLink> URIs.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| <a id="use-stats-based-sharding" /> `--use-stats-based-sharding`                                                 | Enable statistics-based sharding for PostgreSQL sources. This allows sharding of tables with primary keys of any data type and can create more evenly distributed shards compared to the default numerical range sharding. Requires PostgreSQL 11+ and access to `pg_stats`. For details, refer to <InternalLink path="molt-fetch#shard-tables-for-concurrent-export">Table sharding</InternalLink>.                                                                                                                                                                                                                                                                                              |

### `tokens list` flags

| Flag                                         | Description                                                                                                                                                                            |
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <a id="conn-string" /> `--conn-string`       | (Required) Connection string for the target database. For details, see <InternalLink path="molt-fetch#list-active-continuation-tokens">List active continuation tokens</InternalLink>. |
| <a id="num-results" /> `-n`, `--num-results` | Number of results to return.                                                                                                                                                           |

## See also

* <InternalLink path="molt-fetch">MOLT Fetch</InternalLink>
* <InternalLink path="molt-fetch-best-practices">MOLT Fetch Best Practices</InternalLink>
* <InternalLink path="molt-fetch-monitoring">MOLT Fetch Monitoring</InternalLink>
* <InternalLink path="molt-fetch-troubleshooting">MOLT Fetch Troubleshooting</InternalLink>
* <InternalLink path="migration-overview">Migration Overview</InternalLink>
