[英]docker, mongorestore - ERROR: root directory must be a dump of a single database
i had to update a collection on my local machine and want to upload this to a docker instance, here is my procedure 我必须在我的本地计算机上更新一个集合并将其上传到docker实例,这是我的过程
$ #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
this gives me an error 这给我一个错误
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 我只需要还原一个集合而不会删除其他数据,非常感谢任何建议
this worked for me 这对我有用
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 需要确保在转储中仅包含我要还原的集合
I figured out how to do it 我想出了怎么做
NOTE: please explain your question briefly. 注意:请简要说明您的问题。 Question is not clear, please specify where you want to mondodump and restore your data - into server database or your ubuntu running computer. 问题尚不清楚,请指定要在哪里进行还原并将数据还原到服务器数据库或ubuntu运行计算机中。 If into server from your local database then follow following steps:- 如果从本地数据库进入服务器,请执行以下步骤:
Here are the instructions 这是说明
Copy dump folder to server 将转储文件夹复制到服务器
scp -r /local_path/to/dump_folder root@111.222.33.4:/remote/path
SSH into server SSH进入服务器
ssh root@111.222.33.4
Copy from root of server to inside docker container 从服务器根目录复制到Docker容器内部
docker cp dump_folder mongodb:/dump_folder
Go into mongodb docker container 进入mongodb docker容器
docker exec -it mongodb bash
check if copied folder exists ls
(you should see dump_folder, if you named it the same folder as in this example) 检查复制的文件夹是否存在ls
(如果您将其命名为与本示例相同的文件夹,则应该看到dump_folder)
use mongorestore 使用mongorestore
mongorestore --drop -d AppName dump_folder
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.