Skip to main content
Version: 0.15

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
--databaseNoall databassesName of the database to export
--export-jobs, -jNo1Number of parallel export jobs(multiple databases can be exported in parallel)
--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) 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-keyYes*-The s3 access key if s3 is set, this is required
--s3-secret-keyYes*-The s3 secret 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

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)

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
--import-jobs, -jNo1Number of parallel import jobs (multiple databases can be imported in parallel)
--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)