# How to upgrade mongoDB from 4.0 to 5.0?

**URL:** <https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592>\
**Category:** Community Support\
**Created:** [July 31, 2022, 6:53pm UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592 "2022-07-31T18:53:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![nakhg](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@nakhg](https://forums.rocket.chat/u/nakhg)\
**Post date:** [July 31, 2022, 6:53pm UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592/1 "2022-07-31T18:53:26Z")

</div>

### Description

Rocket .Chat server running in Google Cloud vm machine. I want to upgrade the mongoDB version from 4.0 to 5.0. What is the best practice to do the upgrade? including taking backup, restore, etc..

### Server Setup Information

- Version of Rocket.Chat Server:
- Operating System: Ubuntu 18.04
- Deployment Method: /tar/etc (using manual installation guide)
- Number of Running Instances: 1
- DB Replicaset Oplog:
- NodeJS Version: v14.19.0
- MongoDB Version: 4.0.10 / mmapv1
- Proxy: 
- Firewalls involved:

### Any additional Information

All the available guides are either for docker or snap. There is no clear step by step guide for manual installation.  
I would appreciate if someone can provide a step by step guide to do the upgrading.

Thank you

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [August 2, 2022, 5:19pm UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592/2 "2022-08-02T17:19:36Z")

</div>

Hi!

You will also need to migrate from MMAPV1 to WiredTiger.

Consider that mongo 5.0 has some CPU incompatibilities.

It will be basically a dump and restore process. This is more a mongo process than it is a Rocket.Chat process.

Also, consider using docker/k8s instead of manual deployment.

---

<div class="post-metadata">

**Author:** ![nakhg](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@nakhg](https://forums.rocket.chat/u/nakhg)\
**Post date:** [August 3, 2022, 7:34am UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592/3 "2022-08-03T07:34:00Z")

</div>

Thank you for your response.  
“You will also need to migrate from MMAPV1 to WiredTiger.” I am aware of this step I will have to do that first.  
If mongo 5.0 has some incompatibilities issues I will upgrade to 4.4 for now and maybe later to 5.  
Currently I am also thinking move to a cheaper server to host RocketChat, currently it is installed in a vm machine running in Google Cloud.  
You have mentioned Docker/k8s however my previous installation was manual, how can I migrate to Docker is it easy thing to do?  
Also If I moved to a new hosting server, I just need the backup of the mongo database from the current server right?

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [August 3, 2022, 12:47pm UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592/4 "2022-08-03T12:47:59Z")

</div>

Hi! Docker is way easier.

All versions, like node, dependencies and what not is handled by the docker container.

Migrating should be a matter of dumping and restoring the mongo database.

If your filesystem for uploads is GRIDfs, the files should be already there. Otherwise, you need to copy them.

You will then spin up a rocket.chat docker container with the same version you are already at, restore the database, and start migrating and testing.

[Mongo 4.4 end support in February 2024.](https://www.mongodb.com/support-policy/lifecycles)

---

<div class="post-metadata">

**Author:** ![nakhg](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@nakhg](https://forums.rocket.chat/u/nakhg)\
**Post date:** [August 4, 2022, 6:14am UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592/5 "2022-08-04T06:14:37Z")

</div>

Great thank you for the information.  
I will use Docket installation on the new server.  
However I have a few more questions if you dont mind, my current version NodeJs 14.19.0 and MongoDB 4.0.10, RocketChat 4.8.1.  
I am going to install the latest versions on the new server using Docket as you have suggested (it would be great if you could provide me with step by step guide on how to install Rocketchat with Docker)  
Will there be any issue if I restore the database with mentioned versions into the new version?  
Also when i did the dump on the server I did not use docker. This is how I did it `mongodumb --out /backup`.  
Last but not least why Docker no Snap ?

Thank you for your help

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [August 4, 2022, 1:21pm UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592/6 "2022-08-04T13:21:07Z")

</div>

Hi!

You should not have any problems regarding versions and dependencies while using docker. It will isolate your environment and deliver all the necessary bits.

there is a nice step by step here:

> **[Docker & Docker Compose](https://docs.rocket.chat/quick-start/deploying-rocket.chat/rapid-deployment-methods/docker-and-docker-compose)**

With Docker (or Kubernetes) you have more control over the environment, and will not depend on host versions. Also, it’s easier to scale.

Snap is easy to install, but will be closely tied to the host you are running, while docker you can move your deployment without a lot of hassle.

---

<div class="post-metadata">

**Author:** ![nakhg](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@nakhg](https://forums.rocket.chat/u/nakhg)\
**Post date:** [August 4, 2022, 1:32pm UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592/7 "2022-08-04T13:32:41Z")

</div>

Hi @dudanogueira thank you for the information.  
The steps to install Rocket.Chat using Docker is clear and simple. I will install it in the new server.  
One last thing I don`t how to approach it, since I have my monog backup in the old server.  
What should I do in order to use the backup from the old server in the new server where I installed RocketChat using docker?  
I hope I delivered my point clearly

Thank you  
Ghaleb

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [August 4, 2022, 7:53pm UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592/8 "2022-08-04T19:53:25Z")

</div>

Hi!

Once you have the dump at hands, and have a new, clean, fresh install of Rocket.Chat using docker, **with the same version** from the dump (you can upgrade later) you need to restore the data into the docker mongo container.

Here you can have the steps for that:

> **[Docker Mongo Backup and Restore](https://docs.rocket.chat/quick-start/deploying-rocket.chat/rapid-deployment-methods/docker-and-docker-compose/docker-containers/docker-mongo-backup-and-restore)**

After discovering the name of the mongo docker container:

`docker exec -i <database_name> sh -c 'mongorestore --archive' < db.dump`

---

<div class="post-metadata">

**Author:** ![MochiTek](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@MochiTek](https://forums.rocket.chat/u/MochiTek)\
**Post date:** [August 6, 2022, 5:47am UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592/9 "2022-08-06T05:47:50Z")

</div>

Here is a very simple step by step guide i found for upgrading MongoDB from v4.0 to v5.0. Hope this helps!

> **[Upgrading RocketChat Deployed in Docker](https://discussion.scottibyte.com/t/upgrading-rocketchat-deployed-in-docker/69)**
>
> This is a guide to upgrading RocketChat deployed in Docker. RocketChat can be easily upgraded by updating the “RocketChat” container version in your docker-compose.yml file. Once you have updated the version: docker pull...

---

<div class="post-metadata">

**Author:** ![nakhg](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@nakhg](https://forums.rocket.chat/u/nakhg)\
**Post date:** [August 9, 2022, 11:15am UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592/10 "2022-08-09T11:15:43Z")

</div>

Hi I have done the fresh install of Rokcet.Chat with same version of the old server.  
However the database restore step still not clear to me. As you know I was not using docker there and the dump is created using `mongodump --out mongobackup` inside are those files

 ![Screenshot from 2022-08-09 13-11-34](https://us1.discourse-cdn.com/flex021/uploads/rocketchat/original/2X/7/7492a532c454a4d02917ce620946c616d302f17a.png)  
So how can I restore this in docker?

---

<div class="post-metadata">

**Author:** ![nakhg](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@nakhg](https://forums.rocket.chat/u/nakhg)\
**Post date:** [August 9, 2022, 11:16am UTC](https://forums.rocket.chat/t/how-to-upgrade-mongodb-from-4-0-to-5-0/14592/11 "2022-08-09T11:16:46Z")

</div>

Thank you for sharing, this will be helpful after I finish restoring the data.
