Mongodb – How to restore from .wt files

mongodbwindows

Environment
Windows Professional 10
MongoDB 3.6.4 2008R2Plus SSL (64 bit) (before computer crash)
MongoDB 4.0.2 2008R2Plus SSL (64 bit) (after computer crash)

I have been developing locally, and turned on computer today to blue screen of death.

I had no option but to reset Windows 10 and keep personal files.

I therefore have this directory:

C: > data

which contains two directories, db and log.

Below is contents of directory db:

enter image description here

Below is contents of directory log:

enter image description here

I have downloaded and installed:

MongoDB 4.0.2 2008R2Plus SSL (64 bit)

and I accepted the default installation directories:

enter image description here

Question

How can I restore the databases and collections from the contents of my original mongoDB data directory?

Note – I am on the same computer, after a Windows 10 reset, and new install of MongoDB.

Related Questions

There are similar questions below, but they don't seem to provide an authoritative and accepted answer:

How to restore .wt backup file to local MongoDB?

How to copy wt files from another mongo instance?

https://stackoverflow.com/q/37557319

https://stackoverflow.com/q/32551549

Best Answer

Some sort of benevolent magic occurred after doing the following:

Remove MongoDB Community Edition as a Windows Service, see here.

sc.exe delete MongoDB

Then when I went into my favourite MongoDB GUI (Robo3T), the databases were just there!

So i ran:

mongodump  

To get a "proper" dump of all my databases.

I'm confused how this could happen because the databases are still at their original location:

C:\data\

And the new MongoDB installation data location was:

C:\Program Files\MongoDB\Server\4.0\data\

¯_(ツ)_/¯

Atleast I have a proper mongodump backup now.