[英]Restore mongodump database backup, which is the right flow?
I'm performing my first steps with MongoDB but still lost. 我正在执行MongoDB的第一步,但仍然失败。 I have read the docs here but I'm not able to find the the right steps in order to import|restore the DB. 我已经在这里阅读了文档,但是我无法找到正确的步骤来导入|恢复数据库。 I have a .tgz file and I have uncompressed it. 我有一个.tgz文件,并且已将其解压缩。 The output of ll
command is as follow: ll
命令的输出如下:
# ll rs-ds035698_2015-09-21T050031.000Z
total 208
drwxr-xr-x 2 1001 1001 4096 Sep 21 01:00 admin
-rw-r--r-- 1 1001 1001 1037 Sep 21 01:01 oplog.bson
drwxr-xr-x 2 1001 1001 20480 Sep 21 01:01 pdone
drwxr-xr-x 2 1001 1001 20480 Sep 21 01:01 pdone_demo
drwxr-xr-x 2 1001 1001 4096 Sep 21 01:00 pdone_demo_master
drwxr-xr-x 2 1001 1001 4096 Sep 21 01:01 pdone_master
-rw-r--r-- 1 1001 1001 150589 Sep 21 01:01 rs-ds035698_2015-09-21T050031.000Z.log
I need to restore just pdone database. 我只需要还原pdone数据库。 How? 怎么样?
Maybe it will helpful to you.... 也许会对您有帮助。
$mongorestore (It will restore all databases from your dump folder)
Restore particular database from your "dump" folder : 从“转储”文件夹中还原特定的数据库:
$mongorestore --db employee C:\Users\mongo\dump\employee (Here "employee" is new db name)
if you want to import an JSON file then follow this : 如果要导入JSON文件,请遵循以下步骤:
mongoimport -d students -c grades < grades.json
(or)
mongoimport -d students -c grades < C:\Users\mongo\Download\grades.json
Note: here "students" is database name, "grades" is collection name.
Following command is useful for restoring mongodump BSON file. 以下命令对于恢复mongodump BSON文件很有用。 In my case it is user.bason file 就我而言,它是user.bason文件
sudo mongorestore -d ibfs -c log /opt/backup/mongodump-2017-02-01/ibfs/user.bson
Explaination : 说明:
sudo mongorestore -d ibfs(DATABASE_NAME) -c log(COLLECTION_NAME) /opt/backup/mongodump-2017-02-01/ibfs/user.bson(WHOLE PATH)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.