Search code examples
mongodbdatabase-restore

missing collections when restoring MongoDB by copying db files


This method of copying used to work for me. I created a Visual Studio 2010 installer project. I stopped the MongoDB service on my machine and copied my database files (*.ns, *.1, *.2, *.3 and *.4) into the installation. Then I would copy the files during the install to the db directory and start the MongoDB service.

That used to work until I had to add db renaming as an installer feature. now the files rename and copy and show up in mongovue, but the list of collections is blank. What is going on?

Any help would be greatly appreciated. Thanks!


Solution

  • MongoDB uses Journaling by default with 2.0. So this problem can happen when mongodb has data in journal by latency. You check journal latency so you can stop mongo instance after all journal committed. Here is documantation.

    But i strongly recommend you to use mongodump / mongorestore for this job.