How to migrate a local MongoDB database to the cloud for free

Finding a free cloud solution

I was looking for a cheap way to migrate a local MongoDb database, hosted on my NAS to the cloud. Since it was used for a non-revenue-generating side project, I did not want to pay for the hosting, at least initially.

The best solution I found was to migrate it to MongoDB Atlas, a Database as a Service (DBaaS) version of MongoDB that can be hosted in AWS, Azure or Google Cloud. I chose Azure, since the app I was using it with was also hosted there. This is not important at the moment though.

As we can see in the image below, there is a forever free tier option:

Data Migration

After signing up, you can just go and create the new database.

Copying data from the local database using MongoDB Compass

In order to copy your data from the old database:

1) Open MongoDB Compass 2) Go to database and the collections you would like to migrate 3) Go to menu Collection –>Export Collection and export each collection to a JSON file

Inserting data to the cloud database

You can now enjoy your free cloud MongoDB instance!