Question

How to do MongoDB Backups and enhance security?

Posted March 19, 2015 2.7k views
MongoDBUbuntuSecurity

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?

Cheers

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
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 ip.address.to.allow 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:

Submit an Answer