mongodb - 从旧的 mongo 恢复转储
问题描述
我目前正在尝试将使用mongodb:3.4-jessie制作的mongodump恢复到较新的版本mongodb:4.2.3-bionic。
当我尝试执行我的命令时:
sudo docker exec mongo mongorestore —db=mock —gzip /mongorestore/app
它返回给我这个错误:
2020-05-01T00:01:29.405+0000 the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead
2020-05-01T00:01:29.406+0000 Failed: mongorestore target '/home/user1/mongorestore/app' invalid: stat /home/user1/mongorestore/app: no such file or directory
2020-05-01T00:01:29.406+0000 0 document(s) restored successfully. 0 document(s) failed to restore.
该文件夹app
还包含BSON
文件json.gz
。
我无法升级旧的转储,因为它是唯一剩下的东西,并且真的想使用更新版本的 mongo。
非常感谢!
解决方案
我遇到了同样的问题,但使用 Mongo 5,它的工作原理是这样的:
mongorestore --host=hostname --port=portnum \
--archive=/path/to/archive.gz --gzip --verbose \
--nsInclude="mydbname.*" \
--convertLegacyIndexes
mydbname
我在转储集合时使用的数据库的名称在哪里。
如果您现在使用另一个 dbname,那么您需要使用--nsFrom="mydbname.*" --nsTo="newdbname.*"
推荐阅读
- oauth-2.0 - Azure AD 访问令牌中的 scp 声明
- image - ImageCropper.forms 出现错误
- css - 如何从网页复制 CSS 内容?
- java - 我的 libgdx 游戏的某些音频无法在 android 中加载,但可以在桌面上加载
- z-index - 获取 Sybase 中表的索引列表
- python - Python - 搜索中不包含第一个单词
- python-3.x - Python烧瓶蓝图ImportError:无法导入名称'bp'
- apt - MobaXterm apt-get 永久安装包
- express - 将 Express 路由器与 Next.js 一起使用
- kubernetes - 如何从 gitlab-runner 执行滚动更新