# Pritunl update mongodb

**URL:** <https://forum.pritunl.com/t/pritunl-update-mongodb/2234>\
**Category:** Pritunl\
**Created:** [July 26, 2024, 9:21am UTC](https://forum.pritunl.com/t/pritunl-update-mongodb/2234 "2024-07-26T09:21:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![autoeng](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@autoeng](https://forum.pritunl.com/u/autoeng)\
**Post date:** [July 26, 2024, 9:21am UTC](https://forum.pritunl.com/t/pritunl-update-mongodb/2234/1 "2024-07-26T09:21:36Z")

</div>

I have a Pritunl server on Debian Bullseye and need to upgrade to Debian Bookworm, but my version of MongoDB 3.1.11 seems to be incompatible with the latest Debian. What is the best way to update MongoDB without losing data? Is there a guide available? Has anyone else encountered this situation?

I probably will look at the mongo DB procedure. There’s some issue to pay attention in the pritunl ecosystem?

Thanks.

---

<div class="post-metadata">

**Author:** ![autoeng](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@autoeng](https://forum.pritunl.com/u/autoeng)\
**Post date:** [July 26, 2024, 10:47am UTC](https://forum.pritunl.com/t/pritunl-update-mongodb/2234/2 "2024-07-26T10:47:32Z")

</div>

For example, do I need to set “featureCompatibilityVersion” or not?

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [July 26, 2024, 3:40pm UTC](https://forum.pritunl.com/t/pritunl-update-mongodb/2234/3 "2024-07-26T15:40:29Z")

</div>

Before attempting to upgrade the database run `mongodump --db=pritunl`. With MongoDB it will require upgrading 1 release at a time starting with [**MongoDB 3.2 upgrade**](https://www.mongodb.com/docs/v5.3/release-notes/3.2-upgrade/). This would be about 6 steps from that release. It may be better to export the database as documented in the [**backup documentation**](https://docs.pritunl.com/docs/backup) and install the latest MongoDB with an empty database as shown below. Then import the database back and run `sudo pritunl destroy-secondary` to clear the cache data in the database. Sometimes `sudo pritunl repair-database` is also needed this will also rebuild the IP pools.

```auto
mongodump --db=pritunl
sudo systemctl stop pritunl
sudo systemctl stop mongod
sudo yum remove mongodb-org
sudo rm -rf /var/lib/mongo
sudo rm /etc/yum.repos.d/mongodb-org*
sudo tee /etc/yum.repos.d/mongodb-org-6.0.repo << EOF
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc
EOF
sudo yum install mongodb-org
sudo systemctl enable mongod
sudo systemctl start mongod
mongorestore dump
sudo systemctl start pritunl
sudo pritunl destroy-secondary

```

---

<div class="post-metadata">

**Author:** ![autoeng](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@autoeng](https://forum.pritunl.com/u/autoeng)\
**Post date:** [July 29, 2024, 9:34am UTC](https://forum.pritunl.com/t/pritunl-update-mongodb/2234/4 "2024-07-29T09:34:10Z")

</div>

I’m on debian and will utilize the .deb package.  
The above code should be applied to every version of mongo 3.2 - 3.4 - 3.6 - 4.0 - 4.2 - 4.4 - 5.0 - 6.0 ?

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [July 29, 2024, 8:19pm UTC](https://forum.pritunl.com/t/pritunl-update-mongodb/2234/5 "2024-07-29T20:19:55Z")

</div>

No you would need to search Google or the MongoDB documentation for the upgrade instructions for each of those versions. This should be update the repository file to update the package. Then updating the feature compatibility version.

The commands above can be used to skip to the latest release and import a backup of the database.

---

<div class="post-metadata">

**Author:** ![autoeng](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@autoeng](https://forum.pritunl.com/u/autoeng)\
**Post date:** [July 30, 2024, 7:58am UTC](https://forum.pritunl.com/t/pritunl-update-mongodb/2234/6 "2024-07-30T07:58:00Z")

</div>

Excellent. Thanks! I’ll try.

---

<div class="post-metadata">

**Author:** ![autoeng](https://forum.pritunl.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@autoeng](https://forum.pritunl.com/u/autoeng)\
**Post date:** [October 31, 2024, 10:04am UTC](https://forum.pritunl.com/t/pritunl-update-mongodb/2234/7 "2024-10-31T10:04:14Z")

</div>

Dear @zach is mongodb 6.0 the suggested version? I’ve read about issue on v.7. Now it’s out version 8.

Thanks

---

<div class="post-metadata">

**Author:** ![zach](https://forum.pritunl.com/user_avatar/forum.pritunl.com/zach/32/1105_2.png) [@zach](https://forum.pritunl.com/u/zach)\
**Post date:** [October 31, 2024, 11:42am UTC](https://forum.pritunl.com/t/pritunl-update-mongodb/2234/8 "2024-10-31T11:42:14Z")

</div>

The issue in v7 was fixed several months ago, that is the current release in the documentation. I don’t have v8 on any test systems yet but there shouldn’t be any issues. The new Pritunl builds from this month have the latest pyMongo library and should have no compatibility issues.
