I'm using MongoDB version 4

Consider I have a database with dataSize 15GB, storageSize 10GB. After I mongodump --gzip it, the file created is of 5GB.

Now, If I'm restoring it to a remote machine (M2), using mongorestore on my workstation (M1), will the data transferred out of M1 be around 5GB or 10GB or 15GB?


MongoDB 3.4 and newer servers can negotiate network compression if MongoDB clients/drivers have also been updated to support the compressed message format. Network compression was introduced as an optional feature in MongoDB 3.4 and is enabled by default for MongoDB 3.6+ servers.

Unfortunately the mgo driver used by mongodump (as at MongoDB 4.0) does not support network compression and is no longer actively maintained. The expected outcome is that mongorestore or mongodump data transfer will roughly match your dataSize (plus some network overhead).

An officially supported MongoDB Go driver is currently in development and will include full support for the latest MongoDB features. Once the new Go driver is ready, the server command line tools will be updated to be able to take advantage of additional options. A relevant issue to upvote/watch in the MongoDB issue tracker is TOOLS-1668 (Support wire protocol compression in mongodump and mongorestore).

In the interim there are a few possible workarounds if network compression will significantly improve your transfer time to a remote server:

  • Copy the gzipped mongodump file to your remote server and restore locally
  • Use an SSH or VPN connection which supports network compression
  • I'm planning to restore on ATLAS, so cannot copy the file there and locally restore. They have some migration methods in their docs, but I thought this would be the easiest if the data transfer is less Sep 12 '18 at 6:28
  • @DushyantBangal In the case of a managed service you are limited to the options provided. With MongoDB Atlas you could use live migration or mongorestore, but both of those approaches will have similar network requirements at the moment.
    – Stennie
    Sep 12 '18 at 6:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.