How to do MongoDB Backups and enhance security?

March 19, 2015 2.5k views
MongoDB Security Ubuntu

I’m quite new with VPS and now I wish to publish a small project running with MEAN stack.

I wish to know best practices for MongoDB in production.

At the moment I just enabled authentication and changed the port, there is something more I should do?

I was also trying to understand how to do backups and if it is necessary (I think yes) but surfing I didn’t found any good tutorial that explain this.

Can you help me with that?


1 Answer

This tutorial will give you some good pointers for some general security measures to take with your server:

If you are allowing remote access to MongoDB, I’d also suggest implementing firewall rules that restrict what IP addresses are able to access it. The following would allow SSH access on port 22 and restrict incoming access to Mongo’s default port (27017) to a specific IP address:

sudo apt-get install ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow from to any port 27017
sudo ufw enable

This tutorial from the MongoDB docs should point you in the right direction for learning how to backup a MongoDB instance using the mongodump tool:

by Justin Ellingwood
When setting up infrastructure, getting your applications up and running will often be your primary concern. However, making your applications to function correctly without addressing the security needs of your infrastructure could have devastating consequences down the...
Have another answer? Share your knowledge.