Skip to content

forcemeter/etcd-json-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

etcd-json-converter

A simple ETCD export/import tool for backup and restore operations.

Features

  • Export ETCD data to JSON file
  • Import JSON file to ETCD
  • Support key prefix filtering
  • Support limiting number of exported keys

Usage

Export

Export all keys from ETCD cluster:

etcd-json-converter export \
  --endpoint=10.10.0.3:2379,10.10.0.4:2379,10.10.0.5:2379 \
  --file=/tmp/output.json

Export with prefix and limit:

etcd-json-converter export \
  --endpoint=10.10.0.3:2379,10.10.0.4:2379,10.10.0.5:2379 \
  --prefix=/your/prefix \
  --limit=100 \
  --file=/tmp/output.json

Import

Import data from JSON file to ETCD cluster:

etcd-json-converter import \
  --endpoint=10.10.0.3:2379,10.10.0.4:2379,10.10.0.5:2379 \
  --file=/tmp/input.json

Status

Check ETCD cluster status:

etcd-json-converter status \
  --endpoint=10.10.0.3:2379

Docker

Quick Start

Start ETCD and build the tool:

docker compose up -d etcd
docker compose build

Export with Docker

docker compose run --rm etcd-json-converter export \
  -e etcd:2379 \
  -f /data/backup.json

Import with Docker

docker compose run --rm etcd-json-converter import \
  -e etcd:2379 \
  -f /data/backup.json

Check Status

docker compose run --rm etcd-json-converter status -e etcd:2379

Connect to External ETCD

docker compose run --rm etcd-json-converter export \
  -e 10.10.0.3:2379,10.10.0.4:2379 \
  -f /data/backup.json

Note: Exported files are saved in ./data directory.

Tips

Data Migration

You can modify the JSON file before importing for data migration:

# Replace domain names
sed -i 's/baidu.com/google.com/g' /tmp/input.json

# Replace IP addresses
sed -i 's/192.168.1.1/10.0.0.1/g' /tmp/input.json

Options

Option Short Description
--endpoint -e ETCD endpoints (comma-separated)
--file -f JSON file path (default: load.json)
--prefix -p Key prefix for export (default: /)
--limit -l Limit number of keys to export (default: all)

About

一个简单的 ETCD 导出、导入工具,最简单的备份和还原工具; Export/Import/Edit etcd directory as JSON, easy way to backup etcd.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors