如何将转储还原到正在运行的mongodb中 [英] How to restore the dump into your running mongodb

查看:85
本文介绍了如何将转储还原到正在运行的mongodb中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用mongorestore在mongoDB中加载数据/恢复转储数据.我正在尝试指挥

I want to load data/restore dump data in mongoDB using mongorestore. I am trying to command

mongorestore dump

但是它给了我错误

Sat Sep 21 16:12:33.403 JavaScript execution failed: SyntaxError: Unexpected identifier

我们如何还原数据或将数据放入mongoDB?请给我步骤.

How can we restore or put data into mongoDB?? Please give me the steps.

推荐答案

mongodump: 要转储所有记录:

mongodump -db databasename


要限制数据库转储中包含的数据量,可以将--db和--collection指定为mongodump的选项.例如:


To limit the amount of data included in the database dump, you can specify --db and --collection as options to mongodump. For example:

mongodump --collection myCollection --db test

此操作从数据库"test"在当前工作目录的dump/子目录中创建名为myCollection的集合的转储. 注意:如果备份文件文件夹中存在输出文件,则mongodump会覆盖它们.

This operation creates a dump of the collection named myCollection from the database 'test' in a dump/ subdirectory of the current working directory. NOTE: mongodump overwrites output files if they exist in the backup data folder.

mongorestore: 恢复所有数据

1) mongorestore --verbose \path\dump

2) mongorestore --db databasename --verbose \path\dump\<dumpfolder>

注意:两者都需要mongod实例.

Note: Both requires mongod instances.

这篇关于如何将转储还原到正在运行的mongodb中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆