How to upgrade from v3.6.3 to v4.4.5?

I am currently running v3.6.3 on one machine. I have another machine on v4.4.5. I want to move the data from the v3.6.3 machine to the v4.4.5 machine.

I am using ubuntu 18.04

Is this how I should do it:

Make a backup (mongoexport)
Upgrade to mongodb 4.0
Upgrade to mongodb 4.2
Upgrade to mongodb 4.4
Make a backup (mongoexport)
Import the backup data into v4.4.5 machine (mongoimport)

Is all of this needed or can I just mongoexport the data from the v3.6 machine then mongoimport it into the v4.4 machine?

Hi @mental_N_A,

You have multiple solutions to upgrade from MDB 3.6 to 4.4. But before you try anything BACKUP EVERYTHING and of course make sure that you can recreate a 3.6.3 node from your backup so you can always come back and try something else.

  1. The dump solution

mongodump & mongorestore can backup and restore entire databases in a MongoDB cluster. The BSON file they create might not be compatible if the gap between your MongoDB versions is too large (like 2.4 to 4.4 for example). But because 3.6 is not excessively old, it might work just fine.

The big bonus here is that you don’t have to care about recreating your indexes because they will be saved as well in the metadata & they will be rebuilt on the new cluster. And you also don’t need to update 3.6 => 4.0 => 4.2 => 4.4. You can just mongodump in 3.6 and restore in a brand new 4.4 cluster.

It’s not 100% guaranteed that it works as you might find compatibility issues but I would give it a shot.

  1. mongoimport / mongoexport.

This solution is similar to mongodump / mongorestore but instead of using binary files (BSON), you are using plain text JSON files. It’s a lot slower than mongodump / mongorestore & you are not saving the metadata so you will have to recreate the indexes manually.

  1. Upgrading the mongod binaries.

Usually this is the path sysadmins take to avoid down times as it is possible to upgrade your MongoDB Replica Set with a rolling upgrade. This is guaranteed to work this time (unlike the 2 previous methods) but it will require to upgrade from one major version to the next.
In your case, you would have to follow these instructions in this order:

These pages include step by step instructions and contain valuable warnings to avoid surprises like:

Make sure to read these instructions ahead before planning your upgrades and making sure you don’t have anything specific in your MongoDB deployment that would prevent these steps.

EDIT: Adding some links & details about mongodump

Cheers,
Maxime.