本文介绍了docker,mongorestore-错误:根目录必须是单个数据库的转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在我的本地计算机上更新一个集合并将其上传到docker实例,这是我的过程

i had to update a collection on my local machine and want to upload this to a docker instance, here is my procedure

$ #backup local database
$ mongodump --collection styles --db ccc-mongo
$ tar -zcvf dump.tar.gz dump

$ scp dump.tar.gz me@remote:/home/me
$ ssh me@remote
me@remote: ~ $ docker exec -i mongo-dev sh -c "cd /tmp && tar xzf - && mongorestore --collection styles --db ccc-mongo" < dump.tar.gz

这给我一个错误

connected to: 127.0.0.1
Fri Dec 18 16:05:26.768 ERROR: ERROR: root directory must be a dump of a single database
Fri Dec 18 16:05:26.768 ERROR:        when specifying a db name with --db
Import BSON files into MongoDB.

我只需要恢复一个集合而不删除其他数据,任何建议都值得赞赏

i just need to restore one collection without removing the other data, any advice much appreciated

推荐答案

这对我有用

docker exec -i mongo-dev sh -c "cd /tmp && tar xzf - && mongorestore --db ccc-mongo --drop dump/ccc-mongo  && rm -Rf dump"  < dump.tar.gz

需要确保转储中仅包含我要还原的集合仅

need to make sure in the dump to just include the collection i want to restore only

这篇关于docker,mongorestore-错误:根目录必须是单个数据库的转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 18:26