【发布时间】:2021-12-13 16:03:07
【问题描述】:
我想使用标准输出在单个命令行中将 MongoDB 集合复制到另一个数据库。
我不想转储整个数据库。
目标集合的名称与副本不同。
这是我的命令:
> mongodump -h=HOST -d=db1 -c=from_coll --archive --gzip | mongorestore -h=HOST --nsInclude=db2.target_coll --archive --gzip
writing db1.from_coll to an archive on stdout
preparing collections to restore from
done dumping db1.from_coll (100000 documents)
0 document(s) restored successfully. 0 document(s) failed to restore.
mongodump 部分似乎运行良好。
但我们有(0 document(s) restored successfully)
为什么 mongorestore 没有按预期复制目标集合中的数据?
【问题讨论】:
-
option
--gzip没用,因为您无论如何都不存储文件。看看stackoverflow.com/a/67077465/3027266
标签: mongodb mongodump mongorestore mongodb-tools