Skip to main content
Version: Nightly

GreptimeDB Metadata Export and Import Tools

This guide describes how to use GreptimeDB's metadata export and import tools for metadata backup and recovery.

The export and import tools provide functionality for backing up and restoring GreptimeDB metadata.

Export Tool

Command Syntax

greptime cli meta snapshot save [OPTIONS]

Options

OptionRequiredDefaultDescription
--store-addrsYes-Metadata storage service addresses to connect to (only supports etcd MySQL PostgreSQL) format consistent with store-addrs in metasrv configuration
--backendYes-Type of metadata storage backend, one of etcd-store, postgres-store, mysql-store
--store-key-prefixNo""Unified prefix for data in metasrv, refer to metasrv configuration
--meta-table-nameNogreptime_metakvWhen backend is one of postgres-store, mysql-store, the table name storing metadata
--max-txn-opsNo128Maximum number of txn operations
--file-nameNometadata_snapshotFile name for metadata export, will automatically add .metadata.fb suffix
--output-dirNo""Directory to store exported data
--s3NofalseWhether to use s3 as storage medium for exported data
--s3-bucketNo-Valid when s3 is true, s3 bucket name
--s3-regionNo-Valid when s3 is true, s3 region name
--s3-access-keyNo-Valid when s3 is true, s3 access key name
--s3-secret-keyNo-Valid when s3 is true, s3 secret key name
--s3-endpointNo-Valid when s3 is true, s3 endpoint name, defaults based on bucket region, generally not needed

Examples

Exporting metadata from PostgreSQL to s3. This command will export to the metadata_snapshot.metadata.fb file in your-bucket-name:

greptime cli meta snapshot save --store-addrs 'password=password dbname=postgres user=postgres host=localhost port=5432' --backend postgres-store --s3 --s3-bucket your-bucket-name --s3-region ap-southeast-1 --s3-access-key <s3-access-key> --s3-secret-key <s3-secret-key>

Exporting metadata from PostgreSQL to local directory. This command will export to the metadata_snapshot.metadata.fb file in the current directory:

greptime cli meta snapshot save --store-addrs 'password=password dbname=postgres user=postgres host=localhost port=5432' --backend postgres-store

Exporting metadata from etcd to local directory. This command will export to the metadata_snapshot.metadata.fb file in the current directory:

greptime cli meta snapshot save --store-addrs 127.0.0.1:2379 --backend etcd-store

Import Tool

Command Syntax

greptime cli meta snapshot restore [OPTIONS]

Options

OptionRequiredDefaultDescription
--store-addrsYes-Metadata storage service addresses to connect to (only supports etcd MySQL PostgreSQL) format consistent with store-addrs in metasrv configuration
--backendYes-Type of metadata storage backend, one of etcd-store, postgres-store, mysql-store
--store-key-prefixNo""Unified prefix for data in metasrv, refer to metasrv configuration
--meta-table-nameNogreptime_metakvWhen backend is postgres-store, mysql-store, the table name storing metadata
--max-txn-opsNo128Maximum number of txn operations
--file-nameNometadata_snapshot.metadata.fbFile name of metadata export to import, will automatically add .metadata.fb suffix
--input-dirNo""Directory storing exported data
--s3NofalseWhether to use s3 as storage medium for exported data
--s3-bucketNo-Valid when s3 is true, s3 bucket name
--s3-regionNo-Valid when s3 is true, s3 region name
--s3-access-keyNo-Valid when s3 is true, s3 access key name
--s3-secret-keyNo-Valid when s3 is true, s3 secret key name
--s3-endpointNo-Valid when s3 is true, s3 endpoint name, defaults based on bucket region, generally not needed
--forceNofalseWhether to force import, when target backend is detected to not be in a clean state, import is disabled by default, enable this flag to force import

Examples

Importing exported metadata from s3 to PostgreSQL storage backend. This command will import data from the metadata_snapshot.metadata.fb file in your-bucket-name:

greptime cli meta snapshot restore --store-addrs 'password=password dbname=postgres user=postgres host=localhost port=5432' --backend postgres-store --s3 --s3-bucket your-bucket-name --s3-region ap-southeast-1 --s3-access-key <s3-access-key> --s3-secret-key <s3-secret-key>

Importing exported metadata from local file to PostgreSQL storage backend. This command will import data from the metadata_snapshot.metadata.fb file in the current directory:

greptime cli meta snapshot restore --store-addrs 'password=password dbname=postgres user=postgres host=localhost port=5432' --backend postgres-store

Importing exported metadata from local file to etcd storage backend. This command will import data from the metadata_snapshot.metadata.fb file in the current directory:

greptime cli meta snapshot restore --store-addrs 127.0.0.1:2379 --backend etcd-store

Notes

  • Generally, please ensure that the target backend for import is in a clean state, i.e., contains no data. If the target backend already contains data, the import operation may contaminate the data