Skip to main content
Version: 7.0

Ubuntu

danger
  • If a replica set is used — please contact Passwork technical support for proper updating and data preservation.
  • If Passwork is installed on a virtual server, it is recommended to create a virtual OS snapshot before updating.
info

The instructions use switchable code blocks to separate commands according to operating system versions.

Preparation and removal of the outdated version

Creating a backup

Create a directory:

mkdir /backup

Create a backup:

mongodump --out /backup/mongo-$(date +\%Y-\%m-\%d_\%H-\%M-\%S)

Removal

Stop the service:

systemctl stop mongod.service

Move the configuration file:

mv /etc/mongod.conf ./

Remove the database with configuration files:

apt purge mongodb-org* -y

Remove the directory with log files:

rm -r /var/log/mongodb

Remove MongoDB data files:

rm -r /var/lib/mongodb

Remove the outdated repository for MongoDB 4.x:

rm -f /etc/apt/sources.list.d/mongodb-org-4.x.list

Update the list of available packages:

apt-get update

Installation and backup restoration

Installation

Download and convert the MongoDB GPG key to a file:

curl -fsSL https://www.mongodb.org/static/pgp/server-6.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
--dearmor

Add the repository line to the file /etc/apt/sources.list.d/mongodb-org-6.0.list:

echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

Update the list of available packages:

apt-get update

Install MongoDB using the apt package manager:

apt-get install -y mongodb-org

Start the mongod.service:

systemctl start mongod.service

Enable service autostart:

systemctl enable mongod.service

Perform a connection check to the shell:

mongosh mongodb://localhost:27017

Backup restoration

If the connection to the shell is successful, restore the databases from the backup:

mongorestore --drop /backup/mongo-xxxx-xx-xx_xx-xx-xx
danger

If you made changes to the MongoDB configuration file (mongod.conf), you need to replace the new file with the old one:

cp ./mongod.conf /etc/

Restart the mongod.service:

systemctl restart mongod.service

Open Passwork to verify correct operation.