What Is MongoDB Good For?
MongoDB is a popular NoSQL database that powers modern applications that are used for storing product catalogs, processing payments, analyzing IoT data, video games, and many other use cases. It is a distributed database that can scale horizontally and geographically to meet the stringent needs of most modern enterprise applications.
Why Is MongoDB So Popular?
In recent years, MongoDB has gained popularity due to several key capabilities that are essential for modern application development, including:
- High Availability. MongoDB allows you to create replica sets (multiple copies) that are distributed across nodes and uses built-in replication to keep these copies consistent. As a result, your data is highly available in cases of hardware and site failures.
- Horizontal scalability. MongoDB uses sharding to split data across multiple servers, allowing these databases to scale incrementally to a large number of nodes.
- Flexibility. Unlike relational databases that have a predefined schema, MongoDB is a document database with no fixed schema. As a result, it is very flexible in meeting new and emerging application and business requirements.
- Powerful Query Language. With a query language that supports joins, sorting, filtering, aggregating, full text search, and more, developers are able to write complex and very fast queries to meet application requirements.
- Developer Friendly. Document databases such as MongoDB are simpler for developers to learn and start using for new application development.
Given the nature and criticality of modern enterprise applications, it is critical that the underlying data be protected from user errors, ransomware attacks, application corruption, and major natural disasters. Fortunately, MongoDB DBAs and application developers have a lot of choices when it comes to backing up and recovering MongoDB databases. Selecting the right backup and recovery solution is key to ensuring that your data is protected and available with the least amount of disruption.
MongoDB Backup and Recovery: What are the Key Considerations?
There are many factors that go into selecting the right backup and recovery solution for your applications. It is important to ensure that the backup and recovery solution you use meets your needs not just today but well into the future. You’ll need to address several key considerations, including:
- Database Size. Smaller databases can be backed up and recovered quickly, which minimizes application disruption and downtime, and their backup storage consumption is proportionately smaller. For larger databases, you’ll need scalable backup solutions (to reduce backup and recovery times), as well as data deduplication techniques (to reduce backup storage consumption).
- Number of Database Clusters. The complexity of backup and recovery increases with the number of MongoDB clusters you have. Accordingly, a centralized backup solution is more appropriate in these environments.
- Application Availability & Performance. If the application mandates zero downtime and minimum disruption to performance during the backup process, you’ll need a different approach for backup and recovery, such as hot backups (that don’t require downtime) and incremental-forever backups (to eliminate the need for periodic full backups).
- How long will it take to recover data from MongoDB? Business needs will determine the recovery point and recovery time objectives based on the criticality of the application. How much data loss is acceptable and how soon should the data be recovered are critical considerations when choosing a backup and recovery solution. These requirements will determine whether continuous data protection (CDP) is needed or periodic incremental backups are sufficient to meet business needs.
- Granular Backup & Recovery. Flexibility to back up specific collections or, more importantly, restore specific collections (such as in cases of user error or application corruption) requires logical backup methods as opposed to physical backups.
- Archiving Backups to Cloud. To satisfy compliance requirements, backup copies can be archived to the cloud for disaster recovery or to meet long-term data retention needs. A modern backup and recovery solution that is already designed and built for the cloud is more appropriate.
- Integration with Enterprise Applications. Most IT organizations have stringent security and compliance requirements to ensure that only authorized users have access to the data and are able to perform backup and recovery operations. Capabilities such as auditing, role-based access control (RBAC), single sign-on (SSO), and integration with directory services such as Active Directory are very important.
- Ransomware Protection. This is a top-of-mind issue for many organizations — it has become critical to have the ability to have an air-gap solution where backup data is not affected by ransomware attacks.
- Breadth of Database Technologies. Like most organizations, if you have multiple database technologies in use, deploying a separate solution for each database technology is not a practical approach. Centralized backup solutions that support multiple database technologies are more appropriate for these organizations.
How Do I Back Up a MongoDB Database?
There are a number of options when it comes to protecting MongoDB data. The right solution for your organization will depend on some of the key considerations in the previous section. The main choices are:
- Use the bundled mongodump command.
mongodump is a utility that is natively bundled with MongoDB to back up databases. It is a CLI command that reads the contents of the database and writes it to an external file. One of the benefits of mongodump is that you can do granular restores of collections and it also allows you to restore data to an alternate database or cluster. However, it performs a full backup every time and, as such, it is inefficient both from a processing and storage point of view, and therefore affects application performance. How do I schedule a backup in MongoDB? That requires some amount of scripting to automate the process. Considering some of its limitations, this option is best for small databases where application availability and performance requirements are not very stringent. Learn more about how Cohesity’s modern backup and recovery solutions can help. - Copy the underlying database files.
Making physical copies of the underlying database files is another approach to backing up MongoDB databases. It requires you to stop all writes to the database while the files are being copied to ensure that the backups are consistent. However, if the filesystem hosting the database files supports snapshots, the quiesce time can be significantly reduced since filesystem snapshots can be taken within seconds. Journaling will have to be enabled to ensure that the backups are in a consistent state and in a sharded cluster, snapshots across the shards will have to be taken at the same point in time. This approach is very fast when there is a very large number of small documents in a single collection. Also, the impact to the application is less severe both from an availability and performance standpoint. However, all this comes at the cost of not being able to do a granular collection-level restore. Cohesity’s physical backup solution allows you to quiesce the MongoDB database using pre- and post-processing scripts and to use volume-based backups to copy the underlying database files. - Use MongoDB OpsManager.
Organizations that are using the MongoDB Enterprise Advanced subscription have the option to use OpsManager to back up and recover MongoDB databases. OpsManager provides continuous, incremental-forever backup, as well as point-in-time recovery. Advanced features such as backup scheduling, retention management, and the ability to write to an NFS mount or S3-compatible object storage make it a great solution for organizations with many large MongoDB clusters. However, granular collection-level restore is not a simple and straightforward process without a more sophisticated solution. Learn more about Cohesity’s NFS and S3-compatible object storage solutions. - Use a modern backup & recovery solution.
Chances are that most medium-to-large organizations are using many different database technologies for their applications. Deploying database-specific tools for each database type is impractical and can lead to unnecessary complexity in your backup and recovery infrastructure. Additionally, most enterprises have stringent Recovery Point Objectives (RPOs), security, compliance, and reporting requirements that are not easily available in native database tools. Modern backup and recovery solutions can meet stringent RPO requirements by doing continuous backups (CDP) and supporting point-in-time recovery. In addition to backing up MongoDB databases, these solutions help protect Oracle, SQL, VMware, NAS data, Exchange emails, SaaS applications such as M365, and many more. These solutions are also able to provide an air-gap solution that protects against ransomware, ensures that backup data is protected in case of a disaster, and audit trails and reporting to meet compliance needs. Learn more about how Cohesity provides highly scalable data protection for MongoDB databases.
In addition to protecting MongoDB data, Cohesity radically simplifies data management by making it easy to protect, manage, and derive value from data — across the data center, edge, and cloud. Cohesity Helios provides a full suite of services — backup and recovery, disaster recovery, file and object services, and dev/test —- reducing complexity and eliminating mass data fragmentation.