11. Backup and Restore in MongoDB
Activity 11.01: Backup and Restore in MongoDB
Solution:
Perform the following steps to complete the activity:
- Start with
mongoexport
. Remove the--db
option, since you are providing it in the URI.mongoexport --uri=mongodb+srv://USERNAME:[email protected]/sample_mflix --collection=theaters --out="theaters.csv" --type=csv --sort='{theaterId: 1}'
- Add the fields option to the
mongoexport
commandmongoexport --uri=mongodb+srv://USERNAME:[email protected]/sample_mflix --fields=theaterId,location --collection=theaters --out="theaters.csv" --type=csv --sort='{theaterId: 1}'
- Add the necessary CSV options to the import command, that is,
type
,ignoreBlanks
, andheaderline
.mongoimport --uri=mongodb+srv://USERNAME:[email protected]/imports --type=CSV --headerline -...