I have a mongo replicaset on version 3.6.2. I want to upgrade it to 5.0. I do not want to perform the step by step upgrade process. Instead I want to create a new setup i.e replicaset in version 5.0.
I want to migrate the data to the new setup. I am planning to do the below steps:
Take mongo dump using mongodump command in version 3.6.2
Transfer the dump to the new instance
Restore the dump in version 5.0 using mongorestore command
I tried this in the testing environment and it worked just fine. Can this cause any issues with the data. I could not find any info about thi in the mongo docs. Can I face issues later on because of the version difference?
Hello and welcome to the community forum, @Ishrat Jahan!!
We do not suggest you to upgrade directly from 3.6 to 5.0 as there might be a great difference in the features and enhancements between the versions. Please refer to the following documentation here which explains the same.
Therefore, the recommended and tested in-place method is to upgrade the MongoDB version by upgrading sequentially. Hence, for you the upgrade sequence would be 3.6 → 4.0 → 4.2 → 4.4 → 5.0.
The reason why we suggest a step wise upgrade is because each major version is released with new features or enhancements of the legacy features. Hence to maintain the data integrity, the step wise upgrade is recommended. Please refer to the following documentation Upgrade to 5.0 to read more on the same.
In addition, we have a related discussion on a similar topic MongoDB community that you might want to take a look for further information/documentation.
@Aasawari Hi, I am using docker images of mongodb 4.4 in my server, now I want upgrade it to mongodb 7.0,
with docker could i upgrade to 7.0 directly? before that I will dump my data and restore it in mongodb 7.0.
Yes You would need to use the [mongodump](https://www.mongodb.com/docs/database-tools/mongodump/#mongodump) and [mongorestore](https://www.mongodb.com/docs/database-tools/mongorestore/) before you change the image from 4.4 to 7.0
You need to perform the steps below steps to do the upgrade.
If you have the mongo:4.4 running on a container named mongo4.4and has collections as
aasawari.sahasrabuddhe@M-C02DV42LML85 Downloads % docker exec -it mongolatest mongosh
Current Mongosh Log ID: 66224568f7e58a3b14c934dc
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.4
Using MongoDB: 7.0.8
Using Mongosh: 2.2.4
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
test> show dbs
admin 40.00 KiB
config 108.00 KiB
local 40.00 KiB
test 8.00 KiB
test> use test
already on db test
test> show collections
example
test> db.example.find()
[
{ _id: ObjectId('66223ebb7d3bbdb1dfd8a3ae'), name: 'a' },
{ _id: ObjectId('66223ebf7d3bbdb1dfd8a3af'), name: 'b' }
]
Please follow the above steps to perform the upgrade. Also the recommendation would be to perform rolling upgrade in order to avoid any failures.
Please don’t hesitate to reach out for any further questions.