Restore mongodump database backup, which is the right flow?

29 views
Skip to first unread message

Reynier Pérez

unread,
Sep 21, 2015, 11:38:52 AM9/21/15
to mongodb-user
I'm performing my first steps with MongoDB but still lost. I have read the docs [here][1] 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. The output of `ll` command is as follow:

    # 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 collection (I don't know if will be good say DB here). I've tried this:

$mongorestore --db rs-ds035698_2015-09-21T050031.000Z/pdone 
connected to: 127.0.0.1 
don't know what to do with file [dump]

But got that error, what I'm doing wrong? Which is the right way to achieve this?

Jalil AA

unread,
Sep 21, 2015, 12:09:51 PM9/21/15
to mongodb-user
Please post the last 20 lines from your log while you performed the restore..

>> Here is a sample Mongo Import into a single member replica set
mongoimport --host hostname-01:27017 --db mydb --collection CollectionNamezip --file dumpfile

>> But if you have a replica set with 3 members, the import has to be done to all 3 members of RS to keep them in sync.
     Lets say we have 3 members:  hostname-01  hostname-02  hostname-03 - The import would be like so:

> mongoimport --host hostname-01:27017,hostname-02:27017,hostname-03:27017 --db mydb --collection CollectionName --file dumpfile
 
Hope this helps!
@AJ

Reynier Pérez

unread,
Sep 21, 2015, 4:06:31 PM9/21/15
to mongodb-user
Hi there, after a few headaches I was able to restore the database pdone (was my bad to said that was a collection) by using just:

mongorestore rs-ds035698_2015-09-21T050031.000Z/pdone
Reply all
Reply to author
Forward
0 new messages