Bird
Raised Fist0
MongoDBquery~20 mins

Backup and restore strategies in MongoDB - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
MongoDB Backup Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding MongoDB Backup Types

Which of the following backup types in MongoDB allows you to capture the database state at a specific point in time without stopping the database?

ALogical backup
BCold backup
CIncremental backup
DHot backup
Attempts:
2 left
💡 Hint

Think about backups that do not require shutting down the database.

❓ query_result
intermediate
2:00remaining
Result of mongodump Command

What is the expected output when running the command mongodump --db mydb --out /backup/?

AA directory named 'mydb' inside '/backup/' containing BSON data files
BA single JSON file named 'mydb.json' inside '/backup/'
CA compressed archive file named 'mydb.archive' inside '/backup/'
DAn error because --out requires a file name, not a directory
Attempts:
2 left
💡 Hint

Consider how mongodump organizes data when backing up a database.

📝 Syntax
advanced
2:00remaining
Correct mongorestore Syntax

Which of the following commands correctly restores a MongoDB database from a backup directory named '/backup/mydb'?

Amongorestore --restore-db mydb /backup/mydb
Bmongorestore /backup/mydb --db=mydb
Cmongorestore --db mydb /backup/mydb
Dmongorestore --database mydb /backup/mydb
Attempts:
2 left
💡 Hint

Check the official mongorestore syntax for specifying the database and source directory.

❓ optimization
advanced
2:00remaining
Optimizing Backup Speed

You want to speed up the backup process of a large MongoDB database using mongodump. Which option will help achieve this?

AUse --numParallelCollections to dump multiple collections at once
BUse --gzip to compress data during dump
CUse --oplog to include the oplog in the dump
DUse --query to dump only a subset of documents
Attempts:
2 left
💡 Hint

Think about parallelizing work to improve speed.

🔧 Debug
expert
2:00remaining
Troubleshooting mongorestore Failure

You run mongorestore --db mydb /backup/mydb but get an error: Failed: error reading collection data. What is the most likely cause?

AThe MongoDB server is not running
BThe backup was created with --gzip but mongorestore is not using --gzip
CThe mongorestore command is missing the --drop option
DThe backup directory '/backup/mydb' does not contain BSON files
Attempts:
2 left
💡 Hint

Consider if the backup files are compressed and how mongorestore handles them.

Practice

(1/5)
1. What is the primary purpose of creating backups in MongoDB?
easy
A. To protect data from loss or damage
B. To speed up database queries
C. To increase storage space
D. To improve network performance

Solution

  1. Step 1: Understand the role of backups

    Backups are copies of data saved to prevent loss in case of failure or damage.
  2. Step 2: Identify the main goal of backups in MongoDB

    MongoDB backups protect your data so you can restore it if something goes wrong.
  3. Final Answer:

    To protect data from loss or damage -> Option A
  4. Quick Check:

    Backup purpose = Protect data [OK]
Hint: Backups save data safety, not speed or space [OK]
Common Mistakes:
  • Confusing backups with performance improvements
  • Thinking backups increase storage capacity
  • Assuming backups speed up queries
2. Which command is used to create a backup of a MongoDB database?
easy
A. mongorestore
B. mongoload
C. mongoexport
D. mongodump

Solution

  1. Step 1: Recall MongoDB backup commands

    The command mongodump is used to create backups by dumping data.
  2. Step 2: Differentiate from other commands

    mongorestore restores data, mongoexport exports JSON/CSV, and mongoload is not a valid command.
  3. Final Answer:

    mongodump -> Option D
  4. Quick Check:

    Backup command = mongodump [OK]
Hint: Dump means backup; restore means recover [OK]
Common Mistakes:
  • Confusing mongodump with mongorestore
  • Choosing mongoexport which exports data but not backup
  • Selecting a non-existent command mongoload
3. What will happen if you run the command mongorestore --drop dump/?
medium
A. It creates a backup of the database in the dump folder
B. It restores data from the dump folder and drops existing data before restore
C. It exports data to JSON files in the dump folder
D. It deletes the dump folder without restoring data

Solution

  1. Step 1: Understand the mongorestore command with --drop

    mongorestore restores data from a backup. The --drop option deletes existing data before restoring.
  2. Step 2: Analyze the command effect

    Running mongorestore --drop dump/ restores data from the dump folder and removes current data first to avoid duplicates.
  3. Final Answer:

    It restores data from the dump folder and drops existing data before restore -> Option B
  4. Quick Check:

    mongorestore --drop = restore with drop [OK]
Hint: --drop means delete existing data before restore [OK]
Common Mistakes:
  • Thinking mongorestore creates backups
  • Assuming --drop deletes the backup folder
  • Confusing mongorestore with mongoexport
4. You ran mongodump --db mydb --out backup/ but the backup folder is empty. What is the likely mistake?
medium
A. You need to run mongorestore instead of mongodump
B. mongodump command does not support --out option
C. The database name is incorrect or does not exist
D. The backup folder must be created manually before running mongodump

Solution

  1. Step 1: Check command syntax and options

    mongodump supports --out to specify backup folder. The command syntax is correct.
  2. Step 2: Identify common causes for empty backup

    If the database name is wrong or does not exist, mongodump creates no backup files, leaving the folder empty.
  3. Final Answer:

    The database name is incorrect or does not exist -> Option C
  4. Quick Check:

    Empty backup = wrong DB name [OK]
Hint: Check database name spelling if backup folder is empty [OK]
Common Mistakes:
  • Thinking --out is unsupported by mongodump
  • Confusing mongodump with mongorestore
  • Assuming backup folder must exist before running command
5. You want to automate daily backups of your MongoDB database and ensure backups are tested regularly. Which strategy is best?
hard
A. Run mongodump daily via a scheduled task and periodically run mongorestore on a test server
B. Only run mongodump once and keep the backup indefinitely without testing
C. Use mongorestore daily to create backups and mongodump to test them
D. Manually copy database files every week without using mongodump or mongorestore

Solution

  1. Step 1: Identify proper backup automation

    Automating backups requires running mongodump regularly, such as daily, using scheduled tasks or cron jobs.
  2. Step 2: Understand importance of testing backups

    Regularly restoring backups on a test server with mongorestore ensures backups are valid and usable.
  3. Final Answer:

    Run mongodump daily via a scheduled task and periodically run mongorestore on a test server -> Option A
  4. Quick Check:

    Automate dump + test restore = safe backups [OK]
Hint: Automate dump daily and test restore regularly [OK]
Common Mistakes:
  • Not testing backups after creation
  • Using mongorestore to create backups
  • Relying on manual file copying without tools
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard