【问题标题】:MongoRestore is giving me the system cannot find the fileMongoRestore 给我系统找不到文件
【发布时间】:2019-12-30 14:36:26
【问题描述】:

我正在尝试将我的本地 mongodb 数据导出到 atlas 集群,我创建了一个转储,现在我正在使用该命令,

mongorestore --host Cluster0-shard-0/cluster0-shard-00-00-qwo7v.mongodb.net:27017,cluster0-shard-00-01-qwo7v.mongodb.net:27017,cluster0-shard-00-02-qwo7v.mongodb.net:27017 --ssl --username username --password <PASSWORD> --authenticationDatabase admin

尝试恢复它但给我系统找不到指定的文件。 但是如果我输入 mongorestore 那么它可以工作,但它不会恢复到 atlas 云服务器。 我究竟做错了什么?

编辑:我使用的路径是 C:\Program Files\MongoDB\Server\4.2\bin\dump\gfg 和 dump\gfg 但它仍然无法正常工作。

【问题讨论】:

  • 您要恢复什么导出/转储?
  • @Jawad 转储文件夹中的所有数据

标签: mongodb


【解决方案1】:

Usage of MongoRestore.exe can be found here.

独立的 MongoDB

当你使用mongorestore时,你需要提供你需要恢复的文件/转储的位置

mongorestore --host=mongodb1.example.net --port=27017 --username=user --authenticationDatabase=admin /opt/backup/mongodump-2011-10-24

缺少命令的最后一部分,该部分定义了需要恢复的数据的位置。

副本集

要在副本上恢复 MongoDB,您必须停止 mongod 并替换 mongodb 的文件。 Please read here for restoring database on replica set.

对于从独立到副本的还原,

mongorestore --host myReplSet/mongo0.example.com:27020,mongo1.example.com:27012 --db <dbname> <folder_location>

如果这仍然不起作用,请检查路径并确保其正确转义(名称中的空格)或引用。

带引号和路径的代码:

mongorestore --host Cluster0-shard-0/cluster0-shard-00-00-qwo7v.mongodb.net:27017,cluster0-shard-00-01-qwo7v.mongodb.net:27017,cluster0-shard-00-02-qwo7v.mongodb.net:27017 --ssl --username username --password <PASSWORD> --authenticationDatabase admin "C:\Program Files\MongoDB\Server\4.2\bin\dump\gfg"

【讨论】:

  • 我把目录dump/gfg放了但是还是给系统找不到指定的文件
  • 你用过完整路径吗?
  • 是的,我使用了 C:\Program Files\MongoDB\Server\4.2\bin\dump\gfg 和 dump\gfg 但它不起作用
  • 你能用定义的路径更新你的问题吗?
  • 刚刚更新了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-15
相关资源
最近更新 更多