Atlas Backup, mongodump & Restore

🍁 MongoDBLesson 14Advanced

Backing up collections protects data against corruption, accidental drops, and service failures.

1 Backup and Restore Operations
Shell — Backup Commands
# Backup database to a folder
mongodump --db shop_db --out ./backups/

# Restore database from backup folder
mongorestore --db shop_db ./backups/shop_db/

# Export specific collection to JSON
mongoexport --db shop_db --collection products --out products.json

# Import collection from JSON file
mongoimport --db shop_db --collection products --file products.json
2 Code Challenge
Challenge: Run mongodump locally, verify that backup files contain BSON metadata, drop the collection, and restore it from backup files.