Skip to main content
Version: Nightly

Data Export & Import

The Export and Import tools provide functionality for backing up and restoring GreptimeDB databases. These tools can handle both schema and data, allowing for complete or selective backup and restoration operations.

Export Tool

Command Syntax

greptime cli data export [OPTIONS]

Options

OptionRequiredDefaultDescription
--addrYes-Server address to connect
--output-dirYes-Directory to store exported data. Important: This path is on the remote server's filesystem, not your local machine. If you need files locally, configure remote storage (S3/OSS/GCS/Azure Blob) for data export and use --ddl-local-dir to save SQL files to your local filesystem.
--databaseNoall databasesName of the database to export
--db-parallelism, -jNo1Number of databases to export in parallel. For example, if there are 20 databases and db-parallelism is set to 4, then 4 databases will be exported concurrently. (alias: --export-jobs)
--table-parallelismNo4Number of tables to export in parallel within a single database. For example, if a database contains 30 tables and table-parallelism is set to 8, then 8 tables will be exported concurrently.
--max-retryNo3Maximum retry attempts per job
--target, -tNoallExport target (schema/data/all)
--start-timeNo-Start of time range for data export
--end-timeNo-End of time range for data export
--auth-basicNo-Use the <username>:<password> format
--timeoutNo0The timeout for a single call to the DB, default is 0 which means never timeout (e.g., 30s, 10min 20s)
--proxy <PROXY>No-The proxy server address to connect, if set, will override the system proxy. The default behavior will use the system proxy if neither proxy nor no_proxy is set.
--no-proxyNo-Disable proxy server, if set, will not use any proxy
--s3No-If export data to s3
--ddl-local-dirNo-If both ddl_local_dir and remote storage (S3/OSS/GCS/Azure Blob) are set, ddl_local_dir will be only used for exported SQL files, and the data will be exported to remote storage. Note that ddl_local_dir export sql files to LOCAL file system, this is useful if export client don't have direct access to remote storage. If remote storage is set but ddl_local_dir is not set, both SQL&data will be exported to remote storage.
--s3-bucketYes*-The s3 bucket name if s3 is set, this is required
--s3-rootYes*-If s3 is set, this is required
--s3-endpointNo*-The s3 endpoint if s3 is set, this is required
--s3-access-key-idYes*-The s3 access key ID if s3 is set, this is required
--s3-secret-access-keyYes*-The s3 secret access key if s3 is set, this is required
--s3-regionYes*-The s3 region if s3 is set, this is required
--ossNo-If export data to oss
--oss-bucketYes*-The oss bucket name if oss is set, this is required
--oss-endpointNo*-The oss endpoint if oss is set, this is required
--oss-access-key-idYes*-The oss access key id if oss is set, this is required
--oss-access-key-secretYes*-The oss access key secret if oss is set, this is required
--gcsNo-If export data to Google Cloud Storage (GCS)
--gcs-bucketYes*-The GCS bucket name if gcs is set, this is required
--gcs-rootYes*-If gcs is set, this is required
--gcs-scopeNo-GCS service scope
--gcs-credentialNo-GCS credential content
--gcs-endpointNo-GCS endpoint URL
--azblobNo-If export data to Azure Blob Storage
--azblob-containerYes*-The Azure Blob container name if azblob is set, this is required
--azblob-rootYes*-If azblob is set, this is required
--azblob-account-nameYes*-The Azure Blob account name if azblob is set, this is required
--azblob-account-keyNo-Azure Blob account key
--azblob-endpointNo-Azure Blob endpoint URL
--azblob-sas-tokenNo-Azure Blob SAS token

Export Targets

  • schema: Exports table schemas only (SHOW CREATE TABLE)
  • data: Exports table data only (COPY DATABASE TO)
  • all: Exports both schemas and data (default)

Export V2 Tool

The Export V2 tool creates and manages snapshot-based exports. Compared with the legacy export command, Export V2 stores snapshot metadata in a manifest and supports snapshot management commands such as listing, verifying, and deleting snapshots.

Command Syntax

greptime cli data export-v2 <COMMAND> [OPTIONS]

Commands

CommandDescription
createCreate a new snapshot.
listList snapshots under a parent storage location.
verifyVerify snapshot integrity.
deleteDelete a snapshot and all data under it.

export-v2 create Options

greptime cli data export-v2 create [OPTIONS]
OptionRequiredDefaultDescription
--addrYes-Server address to connect, for example 127.0.0.1:4000.
--toYes-Target snapshot location, for example file:///tmp/snapshot or s3://bucket/path.
--catalogNogreptimeCatalog name.
--schemasNoall non-system schemasSchema list to export. Can be specified multiple times or as a comma-separated list.
--schema-onlyNofalseExport schema only, without table data.
--start-timeNo-Start time of the exported data range, in ISO 8601 format.
--end-timeNo-End time of the exported data range, in ISO 8601 format.
--chunk-time-windowNo-Chunk time window, for example 1h, 6h, 1d, or 7d. Requires both --start-time and --end-time.
--formatNoparquetData format. Supported values are parquet, csv, and json.
--forceNofalseDelete an existing snapshot at the target location and recreate it.
--parallelismNo1Parallelism for server-side COPY DATABASE execution, per schema per chunk.
--chunk-parallelismNo1Number of export chunks to run concurrently on the client. Supported range: 1 to 64.
--progressNoautoProgress reporting mode. Supported values: auto, always, never.
--auth-basicNo-Basic authentication in <username>:<password> format.
--timeoutNo60sRequest timeout, for example 30s or 10min 20s.
--proxyNo-Proxy server address. Overrides the system proxy unless --no-proxy is set.
--no-proxyNofalseDisable proxy usage.
--s3, --oss, --gcs, --azblobNo-Enable a remote object store backend. The snapshot URI provides the bucket/container and root path; backend-specific options such as region, endpoint, and credentials are available for the selected backend.

export-v2 list Options

greptime cli data export-v2 list --location <LOCATION> [OPTIONS]
OptionRequiredDefaultDescription
--locationYes-Parent storage location whose direct subdirectories are snapshots.
--s3, --oss, --gcs, --azblobNo-Enable a remote object store backend and its backend-specific options such as region, endpoint, and credentials.

export-v2 verify Options

greptime cli data export-v2 verify --snapshot <SNAPSHOT> [OPTIONS]
OptionRequiredDefaultDescription
--snapshotYes-Snapshot storage location, for example file:///tmp/snapshot or s3://bucket/path.
--s3, --oss, --gcs, --azblobNo-Enable a remote object store backend and its backend-specific options such as region, endpoint, and credentials.

export-v2 delete Options

greptime cli data export-v2 delete --snapshot <SNAPSHOT> [OPTIONS]
OptionRequiredDefaultDescription
--snapshotYes-Snapshot storage location to delete.
--no-confirm, --yesNofalseSkip interactive confirmation.
--s3, --oss, --gcs, --azblobNo-Enable a remote object store backend and its backend-specific options such as region, endpoint, and credentials.

Examples

Export schema only to a local snapshot:

greptime cli data export-v2 create \
--addr 127.0.0.1:4000 \
--to file:///tmp/snapshot \
--schema-only

Export data in a time range to object storage:

greptime cli data export-v2 create \
--addr 127.0.0.1:4000 \
--to s3://bucket/snapshots/prod-20250101 \
--start-time 2025-01-01T00:00:00Z \
--end-time 2025-01-31T23:59:59Z \
--chunk-time-window 1d \
--chunk-parallelism 4 \
--progress auto \
--s3 \
--s3-region us-west-2

Import Tool

Command Syntax

greptime cli data import [OPTIONS]

Options

OptionRequiredDefaultDescription
--addrYes-Server address to connect
--input-dirYes-Directory containing backup data
--databaseNoall databasesName of the database to import
--db-parallelism, -jNo1Number of databases to import in parallel. For example, if there are 20 databases and db-parallelism is set to 4, then 4 databases will be imported concurrently. (alias: --import-jobs)
--max-retryNo3Maximum retry attempts per job
--target, -tNoallImport target (schema/data/all)
--auth-basicNo-Use the <username>:<password> format

Import Targets

  • schema: Imports table schemas only
  • data: Imports table data only
  • all: Imports both schemas and data (default)

Import V2 Tool

The Import V2 tool imports data from snapshots created by Export V2. It supports dry-run verification, schema filtering, progress reporting, and client-side data task parallelism.

Command Syntax

greptime cli data import-v2 [OPTIONS]

Options

OptionRequiredDefaultDescription
--addrYes-Server address to connect, for example 127.0.0.1:4000.
--fromYes-Source snapshot location, for example file:///tmp/snapshot or s3://bucket/path.
--catalogNogreptimeTarget catalog name.
--schemasNoall schemas in the snapshotSchema list to import. Can be specified multiple times or as a comma-separated list.
--dry-runNofalseVerify the snapshot and planned import without executing the import.
--progressNoautoProgress reporting mode. Supported values: auto, always, never.
--task-parallelismNo1Number of import data tasks to run concurrently on the client. Supported range: 1 to 64.
--auth-basicNo-Basic authentication in <username>:<password> format.
--timeoutNo60sRequest timeout, for example 30s or 10min 20s.
--proxyNo-Proxy server address. Overrides the system proxy unless --no-proxy is set.
--no-proxyNofalseDisable proxy usage.
--s3, --oss, --gcs, --azblobNo-Enable a remote object store backend. The snapshot URI provides the bucket/container and root path; backend-specific options such as region, endpoint, and credentials are available for the selected backend.

Examples

Dry-run import from a local snapshot:

greptime cli data import-v2 \
--addr 127.0.0.1:4000 \
--from file:///tmp/snapshot \
--dry-run

Import from object storage with progress reporting:

greptime cli data import-v2 \
--addr 127.0.0.1:4000 \
--from s3://bucket/snapshots/prod-20250101 \
--task-parallelism 4 \
--progress auto \
--s3 \
--s3-region us-west-2