Administration
...
MongoDB
Ubuntu
14 min
if a replication suite is used, please contact passwork technical support to update and save data correctly if passwork is installed on a virtual server, we recommend creating a snapshot before updating this page uses switchable code blocks to provide instructions for different operating systems creating a backup create a directory shell mkdir /backup create a backup shell mongodump out /backup/mongo $(date +\\%y \\%m \\%d \\%h \\%m \\%s) removing the older version stop the service shell systemctl stop mongod service move the configuration file shell mv /etc/mongod conf / remove the database with configuration files shell apt purge mongodb org y delete directory with log files shell rm r /var/log/mongodb delete mongodb data files shell rm r /var/lib/mongodb remove deprecated repository for mongodb 4 x shell rm f /etc/yum repos d/mongodb org 4 x repo update the list of available packages shell apt get update installing mondodb download and add the mongodb gpg key shell 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 mongodb repository to the file ubuntu 22 04 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 ubuntu 20 04 echo "deb \[ arch=amd64,arm64 signed by=/usr/share/keyrings/mongodb server 6 0 gpg ] https //repo mongodb org/apt/ubuntu focal/mongodb org/6 0 multiverse" | sudo tee /etc/apt/sources list d/mongodb org 6 0 list update the list of available packages shell apt get update install the database and administration utilities shell apt get install y mongodb org start the mongod service shell systemctl start mongod service enable autostart of the service shell systemctl enable mongod service perform a shell connection check shell mongosh mongodb //localhost 27017 restoring the backup if the connection to the shell is up, restore the databases from the backup shell mongorestore drop /backup/mongo xxxx xx xx xx xx xx if any parameter changes were made to the mongodb configuration file ( mongod conf ), you must replace the new file with the old one shell cp /mongod conf /etc/ restart the mongod service shell systemctl restart mongod service and open passwork to verify that everything was done correctly