---
keywords: [GreptimeDB CLI, backup, restore, export tool, import tool, database backup, database restoration, command line tool, data export, data import]
description: Introduction to GreptimeDB's data export and import tools for backing up and restoring database data, including command syntax, options.
---

# 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
```bash
greptime cli data export [OPTIONS]
```

### Options
| Option                    | Required | Default        | Description                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------------- | -------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--addr`                  | Yes      | -              | Server address to connect                                                                                                                                                                                                                                                                                                                                                                                                           |
| `--output-dir`            | Yes      | -              | 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.                                                                                                                                     |
| `--database`              | No       | all databases | Name of the database to export                                                                                                                                                                                                                                                                                                                                                                                                      |
| `--db-parallelism`, `-j`  | No       | 1              | Number 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-parallelism`     | No       | 4              | Number 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-retry`             | No       | 3              | Maximum retry attempts per job                                                                                                                                                                                                                                                                                                                                                                                                      |
| `--target`, `-t`          | No       | all            | Export target (schema/data/all)                                                                                                                                                                                                                                                                                                                                                                                                     |
| `--start-time`            | No       | -              | Start of time range for data export                                                                                                                                                                                                                                                                                                                                                                                                 |
| `--end-time`              | No       | -              | End of time range for data export                                                                                                                                                                                                                                                                                                                                                                                                   |
| `--auth-basic`            | No       | -              | Use the `<username>:<password>` format                                                                                                                                                                                                                                                                                                                                                                                              |
| `--timeout`               | No       | 0              | The 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-proxy`              | No       | -              | Disable proxy server, if set, will not use any proxy                                                                                                                                                                                                                                                                                                                                                                                |
| `--s3`                    | No       | -              | If export data to s3                                                                                                                                                                                                                                                                                                                                                                                                                |
| `--ddl-local-dir`         | No       | -              | 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-bucket`             | Yes*     | -              | The s3 bucket name if s3 is set, this is required                                                                                                                                                                                                                                                                                                                                                                                   |
| `--s3-root`               | Yes*     | -              | If s3 is set, this is required                                                                                                                                                                                                                                                                                                                                                                                                      |
| `--s3-endpoint`           | No*      | -              | The s3 endpoint if s3 is set, this is required                                                                                                                                                                                                                                                                                                                                                                                      |
| `--s3-access-key-id`      | Yes*     | -              | The s3 access key ID if s3 is set, this is required                                                                                                                                                                                                                                                                                                                                                                                 |
| `--s3-secret-access-key`  | Yes*     | -              | The s3 secret access key if s3 is set, this is required                                                                                                                                                                                                                                                                                                                                                                             |
| `--s3-region`             | Yes*     | -              | The s3 region if s3 is set, this is required                                                                                                                                                                                                                                                                                                                                                                                        |
| `--oss`                   | No       | -              | If export data to oss                                                                                                                                                                                                                                                                                                                                                                                                               |
| `--oss-bucket`            | Yes*     | -              | The oss bucket name if oss is set, this is required                                                                                                                                                                                                                                                                                                                                                                                 |
| `--oss-endpoint`          | No*      | -              | The oss endpoint if oss is set, this is required                                                                                                                                                                                                                                                                                                                                                                                    |
| `--oss-access-key-id`     | Yes*     | -              | The oss access key id if oss is set, this is required                                                                                                                                                                                                                                                                                                                                                                               |
| `--oss-access-key-secret` | Yes*     | -              | The oss access key secret if oss is set, this is required                                                                                                                                                                                                                                                                                                                                                                           |
| `--gcs`                   | No       | -              | If export data to Google Cloud Storage (GCS)                                                                                                                                                                                                                                                                                                                                                                                         |
| `--gcs-bucket`            | Yes*     | -              | The GCS bucket name if gcs is set, this is required                                                                                                                                                                                                                                                                                                                                                                                 |
| `--gcs-root`              | Yes*     | -              | If gcs is set, this is required                                                                                                                                                                                                                                                                                                                                                                                                      |
| `--gcs-scope`             | No       | -              | GCS service scope                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `--gcs-credential`        | No       | -              | GCS credential content                                                                                                                                                                                                                                                                                                                                                                                                               |
| `--gcs-endpoint`          | No       | -              | GCS endpoint URL                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `--azblob`                | No       | -              | If export data to Azure Blob Storage                                                                                                                                                                                                                                                                                                                                                                                                 |
| `--azblob-container`      | Yes*     | -              | The Azure Blob container name if azblob is set, this is required                                                                                                                                                                                                                                                                                                                                                                     |
| `--azblob-root`           | Yes*     | -              | If azblob is set, this is required                                                                                                                                                                                                                                                                                                                                                                                                   |
| `--azblob-account-name`   | Yes*     | -              | The Azure Blob account name if azblob is set, this is required                                                                                                                                                                                                                                                                                                                                                                       |
| `--azblob-account-key`    | No       | -              | Azure Blob account key                                                                                                                                                                                                                                                                                                                                                                                                               |
| `--azblob-endpoint`       | No       | -              | Azure Blob endpoint URL                                                                                                                                                                                                                                                                                                                                                                                                              |
| `--azblob-sas-token`      | No       | -              | 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)

## Import Tool

### Command Syntax
```bash
greptime cli data import [OPTIONS]
```

### Options
| Option                   | Required | Default       | Description                                                                                                                                                                                  |
| ------------------------ | -------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--addr`                 | Yes      | -             | Server address to connect                                                                                                                                                                    |
| `--input-dir`            | Yes      | -             | Directory containing backup data                                                                                                                                                             |
| `--database`             | No       | all databases | Name of the database to import                                                                                                                                                               |
| `--db-parallelism`, `-j` | No       | 1             | Number 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-retry`            | No       | 3             | Maximum retry attempts per job                                                                                                                                                               |
| `--target, -t`           | No       | all           | Import target (schema/data/all)                                                                                                                                                              |
| `--auth-basic`           | No       | -             | Use the `<username>:<password>` format                                                                                                                                                       |

### Import Targets
- `schema`: Imports table schemas only
- `data`: Imports table data only
- `all`: Imports both schemas and data (default)
