MongoDB – Don’t know what to do with file

mongodbmongodb-3.0

Windows 10 and MongoDB 3.2

I have 2 files. One with .ns extension and one with. They are both in c:\data\dump

I am trying to run

mongorestore -d gnome c:\data\dump

However all I get is

2015-12-11T23:14:12.860+0000    building a list of collections to restore from c:\data\dump dir
2015-12-11T23:14:12.862+0000    don't know what to do with file "c:\data\dump\gnome.0", skipping...
2015-12-11T23:14:12.862+0000    don't know what to do with file "c:\data\dump\gnome.ns", skipping...
2015-12-11T23:14:12.863+0000    done

Any advice?

Best Answer

The .ns file is the file in which MongoDB stores the namespaces of a database. So most likely, what you have is not a dump, but a copy of the datafiles of a single database. Note that this most likely is only a partial copy of a MongoDB instance.

Here is what to do in case you already have an instance of MongoDB running.

  1. Start an other MongoDB instance on another port with the dbpath pointing to the directory with those files.
  2. Connect to the database instance and verify the data.
  3. Make a dump of the data.
  4. Stop the new instance.
  5. Restore the dump to the original instance
  6. Optionally delete the "rogue" datafiles

In case you do not have any instance running yet, simply start MongoDB with dbpath pointing to the directory with the data files or copy the datafiles into your dbpath.