In this answer, I will focus on identifying a few caveats that I experienced for the first time. Hope this proves useful to someone in the same situation. Although the example uses the command line, utilities are available out of the box with the installation of Mongo and can be very well used with C #.
First, make sure your MongoDB installation directory is in the environment path and you can access the mongodump command . MongoDB is usually installed in ~\ProgramFiles\MongoDB\Server\<vr>\bin on Windows.
Once the utility is accessible from CMD, go to the directory in which you want to save the backup (or reset).
Check the mongodump --help options. I used simple (full) backup and restore. So, use the command and specify the necessary parameters. Here is an example:
mongodump /host:ds062199.mlab.com /port:62199 /username:mydbuser /password:mypwd /db:mydbname
The moment you press enter, the utility will create BSON backup files and JSON metadata in the dump/dbname subdirectory.
Now, to restore, follow these steps. Notice that I supported a Mongo instance running on Azure (Mongo Labs) and restored it on my local machine as follows. In the same directory (on cmd) do the following:
mongorestore /host:localhost /port:27017
And it will create a new db as a backup replica on the localhost mongodb instance.
Hope this helps!
source share