Backing up from and restoring to a replica set is not as simple as the basic backup procedure described in Chapter 3, Essential MongoDB Administration Techniques. One problem when using mongodump for backup is that all data needs to pass through the server memory, severely impacting performance.
Another consideration is that the very second the backup has completed, it's already out of date! To avoid overwriting newer data with stale data restored from a backup, you need to carefully consider your backup strategy. The choices for backing up a replica set are as follows:
- Using a filesystem snapshot
- Using mongodump
The tools needed to create a filesystem snapshot depend on the operating system. As such, we do not cover that aspect in this book. If you wish to pursue this approach, a good starting point is the MongoDB documentation, Back Up and Restore Using Filesystem Snapshots.Â