One of the most common scenarios for needing to go to a backup is human error. Someone releases buggy code to production. You drop a collection by accident. Some hackers breached your internal network and dumped political slogans all over your data. Or maybe you’re just worried about such a thing happening, and you want to try starting over, just in case the worst should happen.
Note: Before being able to restore, you would have to configure how to receive the backup files, either HTTPS “pull” or SCP “push” restore formats. If you’re not sure about using HTTPS vs SCP, watch this tutorial.
Now that you’ve decided what format you’d like to use, make sure that whatever machine will be downloading the snapshot has sufficient disk space. On a Linux server, this can be done by running
df -h. In Windows, this information can be found in My Computer by right-clicking on the drive in question. In OSX, you can option-click the relevant hard drive in any Finder window. Then compare it to the size in your Sharded Cluster Status or Replica Set Status page in MMS.
Once you’ve decided on the delivery method, and know you have enough disk space, you can retrieve the snapshot. If you’re running sharded clusters, you can find your snapshots in your Sharded Cluster Status page. If you’re running replica sets, you can find them in your Replica Set Status page. In either case, you then click on the replica set or shard you want to restore and you will see your snapshots. Click on the “restore this snapshot” link for the snapshot you wish to restore. The popup will give you the ability to select the delivery method, and in the case of SCP, test it.
To restore your data, you can either:
- Restore from a Stored Snapshot, which is the fastest restoration method to restore historical information. Data from the stored snapshot will be slightly older than the very latest data received by the backup service, however, depending on the cause of the data corruption this might be acceptable or even ideal.
- Restore from a point in time in the last 24 hours. If you’re sure that your corruption issue took place within the last 24 hours, you can restore from a snapshot prior to when the failure occurred. MMS will then generate a new snapshot at your request based on the your selection via the UI. If the data corruption is from before 24 hours ago, you must restore from a stored snapshot (option #1).
If only one collection or database is corrupted, you may opt to use the mongodump utility in combination with your backup snapshots to pull out the data you need. Once extracted, the data can be imported into a running mongod using mongorestore.
To have this same functionality for sharded clusters, you should configure cluster checkpoints for MongoDB by going to the Sharded Cluster node within MMS Backup and clicking the gear icon that appears next to the cluster. These checkpoints can be configured to take place every 15, 30, or 60 minutes, and you can also decide how long to store each clustershot.
How Buffer uses MongoDB to power its Growth Platform
Control Your Colours in MongoDB Charts
Colours are integral to the story you want to convey with any sort of data visualisation. With the latest release of MongoDB Charts , we have added more control to how you can assign colours to your charts! Previously, colour assignment of a series were always based on the series order within that chart. However, we may instead want to colour the chart based on the series value. Some basic scenarios where these different strategies prove useful include: Colouring the top 3 series with the colours gold, silver and bronze. Colouring the series "Summer" and "Winter" with "Red" and "Blue" respectively, to symbolise the season. If the above examples did not give it away enough, we will create some beautiful charts using an Olympics dataset to fully understand the capabilities of the new features. Single-series charts We will start off with a basic single-series chart. These charts usually have a single field encoded to the x and y axes and will display a single colour for the chart. In these charts, we now show a single colour swatch for you to edit. Simple, right? Multi-series charts For more complicated charts with multiple series, we may want to colour the series based on the encoded field itself. These charts are created when multiple fields are encoded to an aggregation channel where the field key is used to build the multi-series chart. In the above chart, I have a medal tally of the top 10 countries based on medal count. The chart itself is fine, but we could improve this chart with some useful colouring! A notable colour scheme we could apply to this chart is assigning each series to the colour of the medal. Inside the Color Palette customisation option, you will see that each encoded field is now listed based on the order that they were encoded in. With the colour scheme set to the medal colour, the chart will be a lot easier to convey the original information. Colours assigned to these channels will always have the same colour assigned and will ignore the ordering of these fields. Assigning chart colours to string data The final chart that we want to create, involves a chart where the data itself is a String type. With these chart types, the Color Palette will provide options to toggle between the two different colour assignment strategies where: 'By Order' will allow you to assign colours by the ordering of the series 'By Series' lets you customise the colour for a specific series value To help streamline the process of assigning colours in the above chart, in the ‘By Order’ menu, I can choose to assign colours based on the value order of the Discipline that appears in the chart. This may be useful if we don't care what the colours are that represent each Discipline. Alternatively, we could assign colours using 'By Series' so that we can be assured that I can represent the Disciplines with an associated colour. Now that we have created all of our charts using the different ways we can assign colours, we can be confident that the colours in our data visualisations are consistent throughout our dashboard. Want to start colouring your charts today? You can start now for free by signing up for MongoDB Atlas , deploying a free tier cluster and activating Charts. Have an idea on how we can make MongoDB Charts better? Feel free to leave an idea at the MongoDB Feedback Engine .