MMS Backup Cloud service. Also available On-Premise.

The MongoDB Management Service (MMS) is an essential part of any production MongoDB deployment, providing three key functionalities: monitoring, backups, and automation. It is available as a Cloud service or On-Premise. In addition to the powerful web interface, REST APIs are available for programmatic access, scripting, and integration with other systems.

A common use case is to trigger (manually or via cron) the restoration of the latest snapshot from MMS Backup, download the resulting tarballs and store them somewhere for safe keeping (e.g. on tape or to remote datacenter). Sometimes these are kept locally (when using MMS Cloud) for faster restores, or used to automatically reload a test/staging environment with actual production data, scrubbing sensitive information if necessary.

When asked how exactly, we typically refer users to the snapshots and restoreJobs APIs. However, implementing this on your own in a robust manner is non-trivial, especially for users without programming background or the time to do so as it involves parsing the JSON returned via the API. Fortunately, there are community tools like mms-api, a command line tool for the MMS API written in Ruby.

Sadly, installing 3rd party tools that involve external dependencies like Ruby or Python libraries can be challenging or even impossible in some Enterprise environments. Thus a pure Shell/Bash only tool is needed and I’m happy to say that we now have this in the form of mrestore.

Using it to download the most recent snapshot is a simple one-liner like the following:

Which produces output like the following:

Sharded clusters are also supported and produce output like the following (one tarball per shard + one for config server):

For details, refer to the README. Note that this an unofficial tool that I’m maintaining in my spare time. Do try it out and comment here if it works for you (or not)!