Lesson 3: Restore Tools / Learn
Code Summary: Restore Tools
Review the following code, which demonstrates how to use the mongorestore tool.
The following command:
- Restores all of the databases running on the cluster at the URI
"mongodb+srv://dbaTestAdmin@cluster1.xwgj1.mongodb.net/"from a file calledbackup.gz - Unzips the file by using
--gzip - Drops any existing data before restoring the cluster with the data in the file
Here’s the code:
mongorestore \
-v \
--gzip \
--archive=backup.gz \
--drop \
"mongodb+srv://dbaTestAdmin@cluster1.xwgj1.mongodb.net"
The following options can be used with the mongorestore command. Check out the MongoDB documentation for more information.
--nsInclude
--nsExclude
--drop
--noIndexRestore
--writeConcern
--gzip
--archive
--oplogReplay