这篇文章是关于备份流星数据库的
我正在尝试备份流星数据库,并且我了解这篇帖子告诉我要做的事情,但是当我运行mongodump命令时,我一定不在正确的目录中,b/c我一直在获取找不到命令" '.还是我需要导出路径?
I am trying to back up my meteor database and I understand what this post is telling me to do, but I must not be in the right directory when I run the mongodump command, b/c I keep getting 'Command not found'. Or do I need to export a path?
好的,现在我已经安装了二进制文件,但是当我运行"mongodump"时,我得到:
OK, now I have the binaries installed but when I run 'mongodump', I get:
couldn't connect to [127.0.0.1] couldn't connect to server 127.0.0.1:27017...然后运行'mongodump --host localhost:3002',我得到:
... and when I run 'mongodump --host localhost:3002', I get:
couldn't connect to [localhost:3002] couldn't connect to server localhost:3002现在呢?
推荐答案好的,感谢@David Weldon,我可以为这个问题提供一个相当完整的答案:
OK, thanks to @David Weldon, I can provide a fairly complete answer to this issue:
为Meteor用户备份和还原本地MongoDB(OSX)
备份:
1)您的应用程序必须正在运行,因此启动您的Meteor服务器.
1) Your app must be running, so start up your Meteor server.
2)在终端窗口中(不要在流星mongo外壳中输入):mongodump -h 127.0.0.1 --port 3001 -d流星
2) In a terminal window (NOT in the meteor mongo shell), enter: mongodump -h 127.0.0.1 --port 3001 -d meteor
这将在您的主文件夹(您的用户名下)中创建一个转储"目录.
This will create a 'dump' directory inside your home folder (your name under Users).
3)如果收到找不到命令"消息,则可能是Mongo作为Meteor的一部分安装的,这意味着您没有mongo命令行工具.使用Homebrew这样的软件包来重新安装Mongo,您将拥有命令行工具.这还将向您的系统中添加正确的PATH信息,以便它可以找到工具.
3) If you get a 'command not found' message, you probably just installed Mongo as a part of Meteor, meaning you don't have the mongo command line tools. Use a package like Homebrew to reinstall Mongo and you will have the command line tools. This will also add the correct PATH information to your system, so that it can find the tools.
还原:
1)在MiniMongo Shell(在Meteor项目目录中运行"meteor mongo")中,输入:
1) From MiniMongo shell (run ‘meteor mongo’ inside your Meteor project dir), enter:
db.[collectionName] .drop(); //对要还原的所有集合重复
db.[collectionName].drop(); //repeat for all collections you wish to restore
2)然后,从终端窗口中输入:
2) Then, from a terminal window, enter:
mongorestore -h 127.0.0.1-端口3001 -d流星转储/流星
mongorestore -h 127.0.0.1 --port 3001 -d meteor dump/meteor
注意事项:
还原后,各个文档的顺序不一定相同.因此,您需要某种方式对需要按特定顺序显示的文档进行排序.
The individual documents will not necessarily be in the same order after they are restored. So you need some way to sort documents that need to be presented in a certain order.
更多推荐
用mongodump备份流星数据库吗?
发布评论