MongoDB production security and backup I'm quite new to MongoDB and now I was trying to understand the best practices to secure a DB in production and how to automatically backup it.

At the moment for security issues I just changed auth true in the mongod.conf, created a new user for my test DB and changed the port to be something different than 27017.

First question: There is something else to do to enhance security?

Regarding the backup, I have seen different blogs but I didn't understand few things:


Do Mongo create an automatic file for the backup (something called BSON file)?
Is it a good idea to backup the DB every time a value changed?


I wish to understand very well how to be totally safe.

I hope in your help to understand very well the steps I should do to be safe.

Many Thanks
At the moment for security issues I just changed auth true in the mongod.conf, created a new user for my test DB and changed the port to be something different than 27017.
  
  First question: There is something else to do to enhance security?


The MongoDB documentation has a Security Checklist and information on best practices. Aside from enabling authentication you will want to limit network exposure with proper firewall configuration and ensure you are running with secure configuration options (eg. HTTP and REST interfaces disabled). See the checklist for full details.

Changing the port from the default doesn't really enhance security, as that is trivial to discover with a port scanner. You want to have proper network security so potential attackers don't even get as far as connecting.


  Regarding the backup, I have seen different blogs but I didn't understand few things:
  
  Do Mongo create an automatic file for the backup (something called BSON file)?


No, MongoDB does not create backups by default. Recommended backup methods are described in the MongoDB manual. I would consider the MongoDB manual the definitive reference source as it is kept current with product changes. Blog articles may be outdated or contain incomplete/incorrect advice.


  Is it a good idea to backup the DB every time a value changed?


This will depend on your backup strategy. In the general sense, you would not be taking a full backup everything a single value changes using command-line tools like mongodump.

However, a typical deployment uses a replica set which provides for data redundancy and failover across multiple servers. Replication is based on an oplog (operations log) which contains a rolling history of all changes to data that gets replicated to all members of the replica set. Administrative tools like the MongoDB Management Service (MMS) can also use the oplog to create continuous backups and do point-in-time restores.