Mongo dump and restore across machines

Hi!

I am trying to do a mongodump to a json that another dev can use to mongorestore the database. However, when the second dev tries to use this data, it populates the database, but when it comes time to use the data, it doesn’t work (it’s a user-facing application, and the user cannot log in). When I (first dev)
restore from this dump, it works fine. Is there possibly some metadata stored in the bson file that is preventing us from sharing this dump across machines?

These are the commands we are using to dump and restore
mongodump -d test-db -o mock-data
mongorestore -d test-db mock-data/test-db

Does anyone know what may be happening here and/or how to mitigate? I’ve also tried using mongoexport/import with no success.

Welcome to the MongoDB Community @Sofia_Paganin!

The mongodump and mongorestore tools should create identical versions of documents, so there is likely some difference between your two environments (for example tool versions, server versions, timezone versions, or restoring into different databases/collections).

This actually suggests the problem might be something happening after the mongorestore. One possibility is that a person or process is removing the data you are relying on for user login.

To understand more about your scenario can you please:

  • Confirm the Security Measures you have implemented for the deployment you are restoring into.

  • Confirm the db.version() reported for your source deployment and target deployment.

  • Include more information on the query and error that prevents users from logging in. For example, are they unable to login because data is missing, authentication fails, or some other issue?

Thanks,
Stennie

Hi Stennie,

Thanks so much for the reply! I was working with a teammate and we simplified the commands a bit to use the default dump/ folder since we saw that the -d flag was deprecated our use of mongorestore as shown below.

Now we have the following dump and restore commands:
mongodump -d test-db
mongorestore dump/

It turns out the error was in how we were setting up our test database, a difference in environment variables! Thank you for the fast response anyways, it’s much appreciated :smile:

2 Likes

Hi @Sofia_Paganin,

I appreciate you taking the time to share how you solved the problem!

Regards,
Stennie

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.