elasticdump
$ elasticdump 社区开源 中风险elasticdump 用于在集群、本地 NDJSON 文件或 S3 之间迁移 Elasticsearch 与 OpenSearch 的索引 data、mapping、settings、alias 与 template。支持通过 --searchBody 传入 Query DSL 过滤和 --limit 分页,非常适合索引快照与按条件导出。
npm install -g elasticdump elasticdump 通过分页 scroll/PIT 直接将成千上万条 Elasticsearch/OpenSearch 文档流式导出为 NDJSON 文件,大批量索引迁移不适合走 MCP。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
完全非交互运行,支持 --output=$ 标准输出 NDJSON 流、--searchBody JSON 过滤与 --limit,但运行进度日志为纯文本。
- Supports NDJSON files/stdout (
--output=$) and--searchBodyQuery DSL
仅导出时只读本地落盘,但 --delete 参数会在传输后删除源索引文档,且缺少 --dry-run。
- No
--dry-runflag;--deleteflag removes source documents during transfer
可通过 npm install -g elasticdump 或 npx elasticdump 跨平台安装,依赖 Node.js 运行时。
- Distributed on npm (
elasticdump) across macOS, Linux, and Windows
无需配置集群快照仓库即可跨版本迁移 mapping、settings 与过滤后的文档。
- Handles
data,mapping,settings,alias, andtemplatetransfers
长期维护的社区项目(elasticsearch-dump/elasticsearch-dump),采用 Apache-2.0 协议。
- Community-maintained Apache-2.0 repository
仓库 README 与 --help 对各类参数与示例说明详尽。
- Detailed flag reference in repository README
安全边界、鉴权与放权指南
支持在 --input/--output URL 中携带凭据、通过 --headers 传入 JSON 认证头,或读取 S3 所需的 AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY 环境变量。
完全免费,采用 Apache-2.0 开源协议。
# elasticdump Agent Rules - Always export `--type=mapping` and `--type=settings` before moving `--type=data`. - Pass auth via `--headers` from env vars instead of hardcoding `user:pass@` in logged URLs. - Never pass `--delete` on `--input` unless you intentionally want to delete source documents after moving.
Agent 高频安全命令配方
只读查询(安全推荐)
elasticdump --input=http://localhost:9200/logs --output=logs_mapping.json --type=mapping
将 Elasticsearch/OpenSearch 索引的 mapping 模式导出至 logs_mapping.json。
--searchBody 过滤导出错误日志文档 elasticdump --input=http://localhost:9200/logs --output=errors.ndjson --type=data --limit=500 --searchBody='{"query":{"term":{"level":"error"}}}' 按 Query DSL 条件过滤并将匹配的文档以 NDJSON 流式写入 errors.ndjson。
受控写入与预演
elasticdump --input=logs_mapping.json --output=http://localhost:9200/logs_restored --type=mapping
将保存的 mapping 映射应用至新索引 logs_restored。
核心优势
- + 支持结合
--searchBody条件过滤,干净流式传输 NDJSON 数据、mapping 与 settings。 - + 无需集群快照配置即可打通 Elasticsearch、OpenSearch、本地文件与 S3。
注意事项与踩坑点
- ! 缺少
--dry-run参数,且误用--delete会永久删除--input源文档。 - ! 超大索引的 scroll 导出吞吐量低于集群原生 snapshot 机制。