Search code examples
mongodbmigrationrestore

MongoDB backup/restore


In our production MongoDB database, we have a database whose size is around 700GB. We need to migrate data into new MongoDB server which is in a different domain than the current server. Please, anyone, suggest which is the best way to do it?

  1. Should we run dump/restore for this data? Does it require an additional 700GB space to run this command?
  2. Approximately how much time it will take to run dump/restore command? (We have 12gb RAM in server)
  3. Is there any other better way to migrate data into the server which is in a different domain?

Solution

  • You can use mongodump using --gzip parameter, as this will provide 10 fold compression. You will get the backup size around 70 GB.

    How much time it will take for the whole process depends on quite a lot of parameters. However, let me provide a rough estimation

    • Approx 30-40 mins for the backup (mongodump)
    • Assuming you will move it to another server in LAN. It might take 45 mins
    • mongorestore will take close to 30 mins

    A better way if both the servers are in the same network is to configure replica set and add the new server as a replica set member with priority & votes as 0. You can check this link for more details. Once the data is replicated, you can reconfigure the new server to priority 1 & votes 1 and then down the current server.