MCQs Of Day 20: MongoDB Backup and Restore

Rashmi Mishra
0

 

MCQs Of Day 20: MongoDB Backup and Restore



1. Which MongoDB command is used to create a backup of a database?
a) mongorestore
b) mongodump
c) mongoimport
d) mongoexport

Answer: b) mongodump
Explanation: The mongodump command is used to create a backup of a MongoDB database.


2. What does the --out option in mongodump specify?
a) The database name to back up
b) The collection to back up
c) The location where backup files will be saved
d) The type of data to back up

Answer: c) The location where backup files will be saved
Explanation: The --out option specifies the directory where the backup files will be stored.


3. Which MongoDB command is used to restore a database?
a) mongoimport
b) mongodump
c) mongorestore
d) mongoexport

Answer: c) mongorestore
Explanation: The mongorestore command is used to restore a database from a backup.


4. What does the --uri option in both mongodump and mongorestore specify?
a) The path to the database file
b) The MongoDB connection string
c) The name of the collection to be backed up
d) The type of backup

Answer: b) The MongoDB connection string
Explanation: The --uri option specifies the connection string used to connect to the MongoDB server.


5. What command is used to export a MongoDB collection in JSON format?
a) mongorestore
b) mongodump
c) mongoexport
d) mongoimport

Answer: c) mongoexport
Explanation: The mongoexport command is used to export MongoDB data to a JSON or CSV format.


6. Which of the following options can be used with mongoexport to specify the type of file to export?
a) --type
b) --format
c) --output
d) --fields

Answer: a) --type
Explanation: The --type option specifies the format of the export file, which can be json or csv.


7. What is the default format when exporting data using mongoexport?
a) XML
b) JSON
c) CSV
d) BSON

Answer: b) JSON
Explanation: The default format for mongoexport is JSON.


8. How can you back up only one collection from a MongoDB database?
a) Using --collection option in mongodump
b) Using --db option in mongodump
c) By creating a manual backup
d) By using mongoexport

Answer: a) Using --collection option in mongodump
Explanation: The --collection option in mongodump allows you to back up a specific collection.


9. Which command is used to import data into MongoDB from a JSON or CSV file?
a) mongoimport
b) mongorestore
c) mongodump
d) mongoexport

Answer: a) mongoimport
Explanation: The mongoimport command is used to import data from JSON or CSV files into MongoDB.


10. What option in mongoimport allows specifying the target collection?
a) --database
b) --db
c) --collection
d) --table

Answer: c) --collection
Explanation: The --collection option is used to specify the target collection into which data should be imported.


11. What is the default method of backing up a MongoDB database using mongodump?
a) Full database backup
b) Collection-based backup
c) Partial document backup
d) Exporting data to CSV

Answer: a) Full database backup
Explanation: By default, mongodump performs a full database backup, unless specific collections are mentioned.


12. What does the --gzip option in mongodump and mongorestore do?
a) Compresses the backup files
b) Specifies the collection to back up
c) Restricts the data backed up
d) Exports the data in CSV format

Answer: a) Compresses the backup files
Explanation: The --gzip option compresses the backup files to save disk space.


13. Which of the following MongoDB tools is used for exporting collections to CSV?
a) mongodump
b) mongorestore
c) mongoimport
d) mongoexport

Answer: d) mongoexport
Explanation: The mongoexport command can be used to export data in CSV format by specifying --type=csv.


14. Which of the following MongoDB commands allows you to back up the entire database?
a) mongodump
b) mongoexport
c) mongorestore
d) mongoimport

Answer: a) mongodump
Explanation: The mongodump command allows you to back up the entire database.


15. How do you specify the directory to store the backup when using mongodump?
a) --backup
b) --out
c) --directory
d) --location

Answer: b) --out
Explanation: The --out option in mongodump specifies the directory where the backup will be saved.


16. Which MongoDB command restores data from a backup?
a) mongorestore
b) mongoimport
c) mongodump
d) mongoexport

Answer: a) mongorestore
Explanation: The mongorestore command is used to restore MongoDB data from a backup.


17. Which of the following MongoDB tools exports data in CSV format?
a) mongoimport
b) mongorestore
c) mongoexport
d) mongodump

Answer: c) mongoexport
Explanation: The mongoexport command can export data in both JSON and CSV formats.


18. How do you limit the fields to export when using mongoexport?
a) --fields
b) --type
c) --out
d) --db

Answer: a) --fields
Explanation: The --fields option allows you to specify which fields to export in the output file.


19. What is the default output format for mongoimport?
a) BSON
b) CSV
c) JSON
d) XML

Answer: c) JSON
Explanation: The default input format for mongoimport is JSON.


20. Which command is used to verify the restoration of a MongoDB backup?
a) mongodump
b) mongorestore
c) mongo
d) mongoimport

Answer: c) mongo
Explanation: The mongo shell can be used to verify the restoration by checking the data in the collections.


21. Which of the following is true about MongoDB backups?
a) Backups are automatic in MongoDB
b) You need to perform manual backups using commands like mongodump
c) Backups are performed by mongoimport
d) Backups require the use of MongoDB Atlas

Answer: b) You need to perform manual backups using commands like mongodump
Explanation: Backups need to be performed manually using commands like mongodump or scheduled via cron jobs.


22. Which option is used in mongoexport to specify the output file?
a) --file
b) --output
c) --out
d) --export

Answer: c) --out
Explanation: The --out option specifies the output file name for the exported data.


23. What command restores data from a BSON file?
a) mongoimport
b) mongorestore
c) mongodump
d) mongoexport

Answer: b) mongorestore
Explanation: mongorestore is used to restore data from BSON files.


24. What is the effect of using the --drop option with mongorestore?
a) Drops all data before restoring
b) Prevents restoration
c) Only restores specific documents
d) Restores data without any changes

Answer: a) Drops all data before restoring
Explanation: The --drop option removes the existing data in the collection before restoring from the backup.


25. Which option in mongodump allows you to back up specific collections?
a) --collection
b) --db
c) --type
d) --out

Answer: a) --collection
Explanation: The --collection option allows you to specify which collection to back up.


26. Which of the following is a feature of mongorestore?
a) It allows you to backup and restore collections simultaneously
b) It exports data to CSV format
c) It can restore from compressed BSON files
d) It is used only for exporting data

Answer: c) It can restore from compressed BSON files
Explanation: mongorestore can restore data from compressed BSON files if the --gzip option is used.


27. How do you specify the database for a restore operation in mongorestore?
a) --db
b) --database
c) --target-db
d) --restore-db

Answer: a) --db
Explanation: The --db option in mongorestore specifies the target database for the restore operation.


28. How can you backup multiple databases in MongoDB?
a) By using mongodump --out
b) By using mongodump --db for each database
c) By using mongoexport
d) By using mongoimport

Answer: b) By using mongodump --db for each database
Explanation: mongodump --db can be used to back up multiple databases individually.


29. What does the --noIndexRestore option in mongorestore do?
a) Restores all indexes
b) Disables index restoration
c) Only restores data without collections
d) Skips restoring the data

Answer: b) Disables index restoration
Explanation: The --noIndexRestore option disables the restoration of indexes during the restore operation.


30. Which option should be used to back up a replica set using mongodump?
a) --replicaSet
b) --host
c) --out
d) --db

Answer: b) --host
Explanation: The --host option should be used to specify the replica set when using mongodump to back up from a replica set.


31. Which MongoDB command is used to import data from a CSV file?
a) mongoimport
b) mongorestore
c) mongoexport
d) mongodump

Answer: a) mongoimport
Explanation: mongoimport is used to import data from CSV files into MongoDB.


32. How do you restore a backup created with mongodump?
a) By using mongoimport
b) By using mongorestore
c) By using mongodump again
d) By using mongo shell

Answer: b) By using mongorestore
Explanation: To restore a backup created by mongodump, the mongorestore command is used.


33. Which MongoDB utility is used for restoring data from BSON files?
a) mongoexport
b) mongorestore
c) mongodump
d) mongoimport

Answer: b) mongorestore
Explanation: mongorestore is used to restore data from BSON backup files.


34. Which of the following commands is used to backup a specific collection?
a) mongorestore
b) mongodump --collection
c) mongoimport --collection
d) mongoexport --db

Answer: b) mongodump --collection
Explanation: The --collection option in mongodump allows you to back up a specific collection.


35. What is the primary purpose of MongoDB’s mongodump and mongorestore commands?
a) To perform CRUD operations
b) To export and import data
c) To back up and restore data
d) To monitor database performance

Answer: c) To back up and restore data
Explanation: The mongodump and mongorestore commands are primarily used for backing up and restoring MongoDB data.


36. Which command should you use to import a JSON file into MongoDB?
a) mongoimport
b) mongodump
c) mongorestore
d) mongoexport

Answer: a) mongoimport
Explanation: The mongoimport command is used to import JSON files into MongoDB.


37. Which option in mongodump allows you to back up a database without including the system collections?
a) --noSystemCollections
b) --excludeCollection
c) --noIndexRestore
d) --skipSystemCollections

Answer: d) --skipSystemCollections
Explanation: The --skipSystemCollections option allows you to back up a database excluding system collections.


38. What does the --archive option do in mongodump and mongorestore?
a) Saves data in a compressed BSON format
b) Specifies an archive file to store backups
c) Creates an export in CSV format
d) Only includes indexed data

Answer: b) Specifies an archive file to store backups
Explanation: The --archive option in mongodump and mongorestore allows data to be saved and restored from a single archive file.


39. Which of the following tools does MongoDB provide for exporting data?
a) mongoimport
b) mongoexport
c) mongorestore
d) mongodump

Answer: b) mongoexport
Explanation: mongoexport is the tool used to export data from MongoDB.


40. What is the default export format for mongoexport?
a) BSON
b) CSV
c) JSON
d) XML

Answer: c) JSON
Explanation: The default export format for mongoexport is JSON.


41. What is the default behavior of mongodump regarding authentication?
a) It requires no authentication
b) It uses default credentials
c) It prompts for authentication
d) It uses the admin user by default

Answer: a) It requires no authentication
Explanation: mongodump does not require authentication by default unless specified in the connection string.


42. Which option in mongoexport is used to specify the database name?
a) --database
b) --db
c) --db-name
d) --data-source

Answer: b) --db
Explanation: The --db option specifies the database name when using mongoexport.


43. How do you specify the authentication mechanism in mongodump?
a) --auth
b) --username
c) --authenticationMechanism
d) --authMechanism

Answer: c) --authenticationMechanism
Explanation: The --authenticationMechanism option specifies the authentication mechanism when using mongodump.


44. What happens if you run mongorestore without specifying the target database?
a) It restores to the default database
b) It throws an error
c) It restores the data into the original database
d) It skips restoration

Answer: c) It restores the data into the original database
Explanation: If no target database is specified, mongorestore restores the data to the database from the backup file.


45. What does the --noRestore option in mongorestore do?
a) Skips the restoration of indexes
b) Prevents the restoration process
c) Skips restoring the data
d) Restores only the metadata

Answer: c) Skips restoring the data
Explanation: The --noRestore option prevents the restoration of data but can be used to restore indexes.


46. Which backup option in mongodump allows for the backup of large databases?
a) --sharded
b) --split
c) --archive
d) --chunkSize

Answer: d) --chunkSize
Explanation: The --chunkSize option splits large backups into smaller chunks.


47. Which of the following does mongodump allow you to back up?
a) A single MongoDB collection
b) A specific document
c) An entire database
d) Only indexes

Answer: c) An entire database
Explanation: mongodump allows you to back up an entire MongoDB database, but can also be configured to back up specific collections.


48. Can mongorestore restore a backup from a compressed file?
a) Yes, it can restore from both compressed and uncompressed files
b) No, it can only restore from uncompressed files
c) Yes, but only if the file is compressed using gzip
d) No, it does not support compressed files

Answer: a) Yes, it can restore from both compressed and uncompressed files
Explanation: mongorestore supports both compressed and uncompressed BSON files.


49. Which option should be used to restore a backup to a different MongoDB server?
a) --host
b) --uri
c) --db
d) --server

Answer: a) --host
Explanation: The --host option allows you to specify the MongoDB server to which the backup should be restored.


50. Which command is used to export MongoDB data in CSV format?
a) mongoimport
b) mongorestore
c) mongoexport --type=csv
d) mongodump

Answer: c) mongoexport --type=csv
Explanation: mongoexport --type=csv is used to export MongoDB data in CSV format.

 

Tags

Post a Comment

0Comments

Post a Comment (0)

About Me