Moving Your Emergent App's MongoDB Data

How to move an Emergent app's MongoDB data to MongoDB Atlas or your own server. Dumps, restores, indexes, files, users and a clean final sync.

2 min readUpdated

Your Emergent code can go to GitHub in a few clicks. Your live data can’t. Emergent’s help center describes data as hosted on Emergent’s cloud infrastructure, so moving it is its own step.

This is Step 5 of the full Emergent migration guide.

Pick a target

Option Good for Notes
MongoDB Atlas Most teams Managed backups, pick your cloud and region
Self-hosted MongoDB Cost control, on-prem You own backups, upgrades and monitoring
PostgreSQL Heavy reporting, relational data A bigger change: rewrite queries and models

Staying on MongoDB keeps the backend code almost unchanged, since the app already uses a MongoDB driver.

Get the data out

If you have a connection string for the database, use the standard tools:

mongodump --uri "$SOURCE_MONGO_URL" --out ./dump
mongorestore --uri "$TARGET_MONGO_URL" ./dump

If you don’t, add a temporary, authenticated admin endpoint to the FastAPI backend that streams each collection as JSON in pages, then load it with a script. Protect it with a long random token, and remove it after the migration.

Either way, keep the original _id values. Documents often reference each other by ID.

Indexes

mongorestore recreates indexes from a dump. If you exported through an endpoint, recreate them yourself. At minimum:

  • Unique indexes on emails, usernames and slugs
  • Indexes on every field your queries filter or sort by
  • TTL indexes for sessions or tokens, if you have them

Files

If your app stores uploads, find where the files live and what URLs are saved in your documents. Copy the files to S3, Cloudflare R2 or your storage, and rewrite the URLs with a script that’s safe to re-run.

Users

Emergent-built apps usually store users in their own MongoDB collection, often with password hashes created by a library such as bcrypt. If so, users come across with the data and can sign in as before. If the app uses a third-party auth provider, move those accounts through that provider instead.

Prove nothing went missing

Check How
Document counts countDocuments() per collection, source vs. target
Spot checks Open ten random documents per collection in both
References Look for IDs that point to missing documents
Files Count objects, open a random sample
Users Sign in with test accounts of every role

The final sync

Do a full test migration first. On cutover day, freeze writes on the Emergent app, run the export again, check counts, then switch your domain. Keep the dump files somewhere safe as a historical backup.

Ready to migrate off Emergent?

Tell X & Company about your app. You’ll get a straight answer on scope, timeline and cost, and a plan to own your whole stack.