mongodb 流星:如何备份我的 mongo 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16816860/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
meteor: how can I backup my mongo database
提问by kask
How can I make a backup of my meteor mongo database?
如何备份我的流星 mongo 数据库?
If I run:
如果我运行:
meteor mongo
the mongodump command does not work inside the meteor mongoshell
mongodump 命令在meteor mongoshell 中不起作用
回答by kask
First you need to spin up meteor.
首先你需要旋转流星。
Then if you run
那么如果你跑
meteor mongo
you will get an output something like this:
你会得到这样的输出:
MongoDB shell version: 2.2.1
connecting to: 127.0.0.1:3001/meteor
MongoDB 外壳版本:2.2.1
连接到:127.0.0.1:3001/meteor
Meteor db host is at 127.0.0.1 with a port of 3001. Exit the mongo shell and use mongodump from your terminal.
Meteor db 主机位于 127.0.0.1,端口为 3001。退出 mongo shell 并从终端使用 mongodump。
mongodump -h 127.0.0.1 --port 3001 -d meteor
Dumps will be located under the dumps folder in the folder you executed the above command.
转储将位于您执行上述命令的文件夹中的转储文件夹下。
You can import your db back to meteor with
您可以将您的数据库导入到meteor 中
mongorestore -h 127.0.0.1 --port 3001 -d meteor dump/meteor
回答by dani
If you need to backup a meteor application DB deployed to meteor.com follow these steps:
如果您需要备份部署到meteor.com 的meteor 应用程序数据库,请按照以下步骤操作:
- Be sure you are log in into your meteor dev account and generate a temporary connection link:
$ cd yourapp $ meteor login $ meteor mongo yourapp.meteor.com --url
- 确保您登录到您的流星开发帐户并生成一个临时连接链接:
$ cd yourapp $ meteor login $ meteor mongo yourapp.meteor.com --url
You'll get something like:
你会得到类似的东西:
mongodb://client-ID:[email protected]:27017/yourapp_meteor_com
This link expires in 1 minute, so hurry up! :)
此链接将在 1 分钟后失效,所以快点!:)
Create a backupusing mongodump command (http://docs.mongodb.org/manual/tutorial/backup-with-mongodump/#backup-from-non-local):
$ mongodump -h production-db-b1.meteor.io --port 27017 --username client-ID --password password-3be8-f6c5-50a9-password -d yourapp_meteor_com
使用 mongodump 命令创建备份(http://docs.mongodb.org/manual/tutorial/backup-with-mongodump/#backup-from-non-local):
$ mongodump -h production-db-b1.meteor.io --port 27017 --username client-ID --password password-3be8-f6c5-50a9-password -d yourapp_meteor_com
This backup the entire remote database into a default dump/ folder. Voila!
这会将整个远程数据库备份到默认的 dump/ 文件夹中。瞧!
- If ever you need to import the db into local meteor mongo DB, start a mongo shell:
$ meteor mongo MongoDB shell version: 2.4.9 connecting to: 127.0.0.1:3001/meteor
- 如果您需要将数据库导入本地流星 mongo DB,请启动一个 mongo shell:
$ meteor mongo MongoDB shell version: 2.4.9 connecting to: 127.0.0.1:3001/meteor
and in another terminal use mongorestore
command
并在另一个终端中使用mongorestore
命令
$ mongorestore --port 3001
$ mongorestore --port 3001