This page describes how to back up and restore the MongoDB database used by Itential Platform. The following strategy minimizes downtime, maximizes efficiency, and helps prevent service level agreement (SLA) breaches.
Itential recommends these backup practices:
mongodump to capture all database data once per day.You can capture hourly snapshots in binary format or JSON format. Itential prefers binary format and recommends using it whenever possible.
Ensure you identify and back up the following files before restoration. The locations below are defaults and may vary in your installation.
You can only export and import from the primary MongoDB server in the replica set. Connect to the primary server, then use mongoexport or mongodump to export content to the appropriate directory. Move the data to the target server and use mongoimport or mongorestore to recover from these backups.
For complete MongoDB documentation, see the MongoDB backup and restore tools guide.
Use mongodump for binary backups or mongoexport for human-readable JSON format.
When you restore a member of a replica set, MongoDB ensures that the new member doesn’t become the primary until it syncs with the existing replica set. MongoDB controls this automatically through member states, but you can also manually control whether a member can become primary by setting its priority.
If you add a new member to a replica set, or if an existing member has been out of service for an extended period, MongoDB initiates a series of steps to bring that member in line with the existing members.
mongod loads the member’s replica set configuration and transitions the member to STARTUP2.mongod finishes loading the configuration.STARTUP2 until all data is copied and all indexes are built, then transitions to RECOVERING.SECONDARY after replicating enough data for consistent client reads. The only difference between RECOVERING and SECONDARY is that RECOVERING prohibits client reads while SECONDARY permits them.To prevent a secondary member from becoming primary during failover, assign it a priority lower than the primary member’s priority.
Example: Your current primary is m1.example.net and you want to make m3.example.net the primary. You have a three-member replica set with the following configuration:
The following sequence occurs automatically:
m3.example.net and m2.example.net sync with m1.example.net (typically within 10 seconds).m1.example.net detects it no longer has the highest priority and steps down. If m3.example.net’s sync is far behind, m1.example.net waits until m3.example.net is within 10 seconds of its optime before stepping down.m3.example.net becomes primary based on its priority setting.Use the appropriate restore command based on your backup method.
If you used mongodump to create the backup, use mongorestore to restore it:
If you used mongoexport to create the backup, use mongoimport to restore it:
For more information, see the MongoDB replica set restoration documentation.
After completing the backup and recovery process, consider these additional measures: