用mongodump备份流星数据库吗?

编程入门 行业动态 更新时间:2024-10-22 14:34:47
本文介绍了用mongodump备份流星数据库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这篇文章是关于备份流星数据库的

我正在尝试备份流星数据库,并且我了解这篇帖子告诉我要做的事情,但是当我运行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备份流星数据库吗?

本文发布于:2023-08-05 21:29:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1308160.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:备份   流星   数据库   mongodump

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!