# Upgrading MongoDB From Previous Versions
# Guide is specifically for Monolithic but should work for any mongodb data. Just be aware of the versions.
If your still on the older version, you can skip part 1. Just exec into the octofarm container and run the commands from there... the "some_mongo" name will be different though.
- Start mongodb 3.2 container
docker run -v /{replace with your data directory}/:/data/db --name some_mongo -d mongo:3.2
- Go into the containers CLI
docker exec -it some_mongo bash
- Make a new "dump" directory
mkdir /data/db/dump
- Use mongodump to backup the database
mongodump -d octofarm -o /data/db/dump
- Exit the docker container cli
exit
- Clean up the old container and move the dump somewhere safe
sudo docker stop some_mongo
sudo docker rm some_mongo
sudo mv /{replace with your data directory}/dump/octofarm ~/{your safe dir}
- Nuke you data dir folder
rm -Rf /{replace with your data directory}/
- Spin up a mongodb 4.4.14 container (this is what the new monolithic image uses), then stop it
docker run -v /{replace with your data directory}/:/data/db --name some_mongo -d mongo:4.4.14
docker stop some_mongo
- Change into your newly created local directory, create a folder called dump and add back in the octofarm dump.
cd /{replace with your data directory}/
sudo mkdir dump
sudo cp -r ~/{your safe dir} /{replace with your data directory}/dump
docker start some_mongo
- Back into the containers CLI
docker exec -it some_mongo bash
- Restore your database dump
mongorestore /data/db/dump/octofarm/ --db octofarm
You should see something like: 2022-05-22T02:03:41.594+0000 # document(s) restored successfully. 0 document(s) failed to restore.
- Exit the container and remove the 4.4 image.
exit
docker stop some_mongo
docker rm some_mongo
That's it! Your database will be updated to mongo v4.4. You just need to update your container and restart if you haven't already updated.