Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › APT

How to Upgrade MongoDB on Ubuntu Without Losing Data

By Freedom251 Team · · 9 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The safest MongoDB upgrade on Ubuntu is a controlled, reversible change—not a blind apt upgrade. Record the current server and topology, take a backup that you have actually restored in a test environment, follow MongoDB’s release-specific version path, upgrade binaries before enabling new features, and keep a rollback or restore decision ready. A standalone normally incurs downtime; a healthy replica set can be upgraded member by member.

What “without losing data” can realistically mean

No procedure can promise zero risk without knowing your MongoDB release, Ubuntu version, topology, storage layout, authentication, and backup system. The defensible goal is a recoverable change:

As an Amazon Associate I earn from qualifying purchases.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Use MongoDB’s supported path for the exact source and target releases.
  • Preserve a verified backup, configuration, permissions, and the old packages or binaries.
  • Change one risk at a time: packages first, feature compatibility version (FCV) later.
  • Define when applications will be stopped, redirected, rolled back, or restored.

mongodump and mongorestore are logical backup tools. They do not make an unsupported version jump safe, and restoring into a newer deployment is not MongoDB’s recommended upgrade method. Use the dump as a recovery option and as evidence that you can restore, while still following the supported binary-upgrade sequence.

Discover the installation before planning commands

Run the following as an administrator with access to the MongoDB service and shell. Save the output with your change record.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
mongod --version
mongosh --quiet --eval 'db.version()'
sudo systemctl status mongod --no-pager
apt-cache policy mongodb-org mongodb-org-server

Connect to the running deployment and record its topology and FCV:

db.adminCommand({ hello: 1 })
db.adminCommand({ getParameter: 1, featureCompatibilityVersion: 1 })

For a replica set, also inspect member health and state:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
db.adminCommand({ replSetGetStatus: 1 })

Do not start an upgrade while any member is in ROLLBACK or RECOVERING. Resolve replication, storage, or authentication problems first.

Record Why it matters
MongoDB binary and shell versions Establishes the source release and helps select the allowed intermediate releases.
Ubuntu codename and architecture The official repository is version- and distribution-specific.
Topology and member states Determines whether you need downtime, a stepdown, or member-by-member sequencing.
Repository file and package versions Prevents an accidental repository switch or unrelated package movement.
Configuration, data, log, and key-file paths Lets you recreate the service with the same settings and permissions.
Authentication, TLS, drivers, and maintenance dependencies These can fail even when the server process starts successfully.

Back up MongoDB and prove the backup works

Take a logical dump appropriate to the topology

For a full replica-set dump, use the Database Tools release appropriate for your server and include the operation log when the topology permits it:

mongodump --uri='mongodb://USER:PASSWORD@HOST/?authSource=admin' 
  --out /var/backups/mongodb/$(date -u +%Y%m%dT%H%M%SZ) 
  --oplog

--oplog captures writes occurring while the dump runs; a restore can replay them with mongorestore --oplogReplay. MongoDB documents that this option requires a full dump from a replica-set member. It cannot be used for a sharded-cluster dump and is incompatible with options that restrict the dump, such as limiting the dump to selected namespaces. If those restrictions apply, use an approved backup method for that deployment instead.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Check tool compatibility and the files

The cited Database Tools documentation covers server versions 4.2 through 9.0 and Ubuntu 16.04 through 24.04 for that tools release. Confirm the tool version against your server before relying on the output, and use the same Database Tools release for restoration when possible; MongoDB warns that format differences can cause restore failure or incorrect data.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify that the dump contains the expected databases, collections, metadata, and operation-log file where applicable. Protect credentials and backup permissions, and copy the backup to storage that will survive a failed package change.

Perform an isolated restore test

  1. Start a temporary MongoDB instance or isolated host that cannot receive production traffic.
  2. Restore the dump with the matching Database Tools release. Use --oplogReplay only when the dump was made with a usable oplog.
  3. Compare collection counts and indexes with production records.
  4. Run representative application reads and writes against the isolated instance, including authentication and role checks.
  5. Record the restore date, tool versions, commands, warnings, and the time required. A backup that has never restored is not a rollback plan.

Keep users, roles, TLS material, key files, and any metadata required by your chosen backup method. A data dump alone may not recreate the complete service.

Choose the supported MongoDB version path

Read the exact MongoDB upgrade page for your source release, target release, and topology before changing the repository. MongoDB’s self-managed procedures are release-specific. In MongoDB versions before 9.0, minor releases cannot be skipped when upgrading a self-managed deployment. Do not assume that the newest package can be installed directly over an old one.

Build a written path such as “current release → required intermediate release → target release,” including the required FCV at each stage. Check release compatibility changes, storage and operating-system requirements, and the compatibility of every application driver and integration. Test the target driver versions before the maintenance window when the release notes require it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

MongoDB separates binary changes from feature activation: “Upgrading the MongoDB binaries and enabling the new version’s features are two separate steps.” New binaries can normally run with the previous FCV while you validate the deployment. Raising FCV enables behaviors and data formats that older binaries may not understand, so it belongs only after the burn-in checks.

Control Ubuntu’s apt state

Save the current package state

Copy the MongoDB repository file, list installed package versions, and capture enabled package holds before editing apt configuration. Also preserve /etc/mongod.conf (or your actual configuration path), service overrides, key files, ownership, and permissions.

sudo cp -a /etc/apt/sources.list.d/mongodb-org-*.list /var/backups/mongodb/
dpkg-query -W 'mongodb-org*' 2>/dev/null
apt-mark showhold

The filename may differ on your host; copy the actual version-specific MongoDB source file rather than assuming a path.

Point apt at the target repository deliberately

Use MongoDB’s official Ubuntu installation instructions for the target release, Ubuntu codename, and architecture. The repository series controls which server and tool packages apt sees. After changing it, inspect the candidate versions before installing:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
apt-cache policy mongodb-org mongodb-org-server

Do not accept a candidate from an unintended Ubuntu or MongoDB series. apt-get can move packages whenever a newer candidate is available, so package holds or an explicit package-version install may be appropriate when you need a tightly controlled change. Document how any hold will be removed for the next planned upgrade.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Upgrade a standalone safely

A standalone has no member to take over if it is stopped. Plan a maintenance window, stop or drain application writes, and verify that you can restore or reinstall the previous package set before proceeding. MongoDB recommends considering conversion to a replica set before upgrading, especially when downtime and recovery risk are unacceptable.

  1. Announce the window and freeze writes. Stop application workers or redirect them to a maintenance endpoint. Confirm that no process will keep writing while the server is down.
  2. Complete and verify the backup. Use the tested dump or your approved physical backup. Confirm that the destination has enough free space and that the restore test passed.
  3. Record a final health snapshot. Save systemctl status, package versions, disk usage, configuration, and relevant log messages.
  4. Stop MongoDB cleanly. Use the service name configured on your Ubuntu host:
sudo systemctl stop mongod
sudo systemctl status mongod --no-pager
  1. Install only the intended target package versions. Refresh apt metadata after pointing at the target repository, review the transaction, and install the server and companion packages required by the release-specific procedure. Avoid an unreviewed system-wide upgrade.
  2. Start and inspect the service.
sudo systemctl start mongod
sudo systemctl status mongod --no-pager
mongosh --quiet --eval 'db.version()'
  1. Run the burn-in checks before changing FCV. Review the MongoDB log, run representative queries, confirm indexes and authentication, and watch disk, memory, and latency. If the server will not start, stop applications and follow the rollback decision rather than deleting the data directory.
  2. Raise FCV only after validation. Use the exact command and confirmation syntax on the target release page. For a 9.0 procedure, the form is:
db.adminCommand({ setFeatureCompatibilityVersion: "9.0", confirm: true })

Do not copy that value for another release. FCV changes internal state; use the target release’s documented value and prerequisites.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Upgrade a replica set member by member

Replica sets reduce application downtime but add sequencing requirements. All members must reach the prerequisite release, members must remain healthy, and FCV operations require majority availability. Never begin while a member is in ROLLBACK or RECOVERING.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Check redundancy. Confirm that the set has a healthy voting majority, adequate disk space, and acceptable replication lag. Identify the primary, secondaries, hidden members, arbiters, and any member undergoing initial sync.
  2. Upgrade secondaries first. One member at a time, remove or stop it according to MongoDB’s release-specific procedure, install the target packages, restart it, and wait for it to return to a healthy state and catch up.
  3. Recheck status after every member. Use replSetGetStatus, inspect logs, and verify that applications still have a writable primary and a majority.
  4. Step down the primary deliberately. Follow the target release’s documented stepdown procedure and application retry settings. Allow a new primary to be elected before upgrading the former primary.
  5. Upgrade the former primary. Install the same target packages, restart, and wait for it to rejoin and synchronize.
  6. Burn in the entire set. Test failover, replication, reads and writes, monitoring, backups, and driver behavior while the old FCV remains in force.
  7. Raise FCV on the primary. Use the exact target-release command only when the required majority of data-bearing members is available. Do not run an FCV change during an initial sync.

A rolling upgrade is not a license to skip intermediate releases: apply the release-specific sequence to each required version in the path.

Keep FCV unchanged during the burn-in period

After binaries restart on the target version, leave the previous FCV enabled while you validate:

  • Replica-set state, election behavior, replication lag, and majority availability.
  • MongoDB logs for startup warnings, incompatibilities, authentication failures, and storage errors.
  • Representative application transactions, indexes, aggregations, change streams, and driver retries.
  • Backup execution and a restore of data written after the binary upgrade.
  • Resource use and operational tooling, including monitoring, alerts, and scheduled jobs.

Only when these checks pass should you execute the target release’s FCV command on the primary. FCV is a deliberate compatibility boundary, not an automatic finishing step.

Rollback and recovery decisions

Decide your recovery branch before the maintenance window:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Condition Preferred response
Package installation failed before data files were opened Correct the apt repository or package set and reinstall the documented version.
New binary starts but an application or driver fails during burn-in Keep FCV unchanged, stop or redirect clients, and follow the release-specific downgrade guidance using the preserved packages and configuration.
A standalone cannot start or data files are damaged Do not repeatedly modify the data directory; preserve logs and restore the verified backup to an isolated or replacement instance.
A replica-set member fails Keep the remaining healthy majority serving if safe, isolate the failed member, and recover or resync it according to MongoDB’s procedure.
FCV has been raised Do not assume a binary downgrade is safe. Consult the target release’s downgrade and FCV rules; restoration may be the appropriate recovery path.

Restoring a backup can lose writes made after the backup unless your backup method captured and replayed them. Record the recovery point and communicate that boundary before directing applications to a restored service.

Common apt and upgrade failures

Apt selects an unexpected MongoDB version

Inspect apt-cache policy, the active source file, and package holds. A stale repository, mixed Ubuntu codename, or unheld package can change the candidate. Correct the source, refresh metadata, and review the transaction again before installing.

The service starts but clients cannot connect

Check the bind address, port, TLS settings, authentication database, key-file permissions, firewall rules, and driver compatibility. Compare the active configuration with the saved pre-upgrade copy; a package change should not silently become a configuration migration.

A replica set loses majority

Stop the rolling sequence. Check member health, network reachability, clock and storage errors, and replication lag. Do not raise FCV until the required majority of data-bearing members is available.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The dump cannot be restored

Confirm that the Database Tools release matches the dump and server as closely as possible, that the dump was complete, and that you are not using --oplogReplay with a dump that lacks a valid oplog. Test the restore on an isolated instance rather than experimenting against production.

Final pre-flight checklist

  • Exact source, intermediate, and target releases are written down from MongoDB’s version guide.
  • Ubuntu codename, repository file, candidate packages, and package holds are recorded.
  • Configuration, data and log paths, permissions, TLS material, and key files are backed up.
  • Application drivers and integrations are compatible with the target release.
  • A complete backup exists on separate storage and has passed an isolated restore test.
  • Standalone downtime or replica-set sequencing, stepdown, and client retry behavior are scheduled.
  • Health, replication, logs, representative queries, and backups will be checked before FCV changes.
  • Old packages or binaries and a documented rollback or restore decision are available.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

APTbackupsDatabase administrationMongoDBreplica setsUbuntu

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.