How to Migrate MongoDB from One Cloud to Another (Complete Guide)
Migrating MongoDB from one cloud to another is a common task when:
- Moving to a new hosting provider
- Creating backup before major updates
- Cloning production to staging
- Changing MongoDB Atlas account
- Migrating client infrastructure
This guide explains the safest professional method to migrate MongoDB between cloud providers.
Supported systems:
- Windows
- Linux
- macOS
Tools used:
- mongodump (export database)
- mongorestore (import database)
Migration Architecture
Old MongoDB Cloud → Backup → Local System → Restore → New MongoDB Cloud
Steps:
- Export database from old cloud
- Save backup locally
- Restore to new cloud
- Verify data
Requirements
Old MongoDB URI
mongodb+srv://username:password@oldcluster.mongodb.net/olddb
New MongoDB URI
mongodb+srv://username:password@newcluster.mongodb.net/newdb
Install MongoDB Database Tools
https://www.mongodb.com/try/download/database-tools
Windows Migration
Step 1 — Dump Database
Open CMD and run:
mongodump --uri="OLD_URI" --out="C:\backup"
Step 2 — Restore Database
mongorestore --uri="NEW_URI" "C:\backup\olddb"
Linux Migration
Install tools
sudo apt update sudo apt install mongodb-database-tools -y
Dump
mongodump --uri="OLD_URI" --out=/home/backup
Restore
mongorestore --uri="NEW_URI" /home/backup/olddb
macOS Migration
Install tools
brew tap mongodb/brew brew install mongodb-database-tools
Dump
mongodump --uri="OLD_URI" --out=~/backup
Restore
mongorestore --uri="NEW_URI" ~/backup/olddb
Backup First (Important)
mongodump --uri="OLD_URI" --out=backup
Keep backup safe before migration.
Copy One DB to Another Name
mongodump --uri="mongodb+srv://old/test" --out=dump mongorestore --uri="mongodb+srv://new/production" dump/test
Production Tips
✔ Always take backup
✔ Stop writes during migration
✔ Verify collections
✔ Test on staging
✔ Check data after migration
Verify After Migration
show dbs
use dbname
show collections
Author
Marquefactory DevOps Team
