narbulut

How to Back Up a MongoDB Database?

17 May, 2026

Your data is the most valuable asset of your business. A hardware failure, an accidentally deleted collection, or a ransomware attack can destroy years of accumulated data in seconds. If you use a modern, flexible database like MongoDB, a regular and proper backup strategy is not a preference but a necessity.

In this guide we cover the three core methods of backing up MongoDB — from simple to advanced — in language anyone can understand: logical backup (mongodump), physical backup (snapshot), and cloud-based managed backup. We’ll also help you decide which one is right for you.

First, the Basic Concepts

When choosing a backup method in MongoDB, two things are decisive: the size of your database and your deployment type (single server, replica set, or sharded cluster). While the simplest method is enough for a small database, large and distributed systems require different approaches.

Backup methods are broadly divided into three:

  • Logical backup: Exports the data into a readable/portable format. Flexible but slow on large data.
  • Physical backup: Takes a direct copy of the database files. Very fast, ideal for large data.
  • Cloud / managed backup: Delegates the backup job to a service. No setup hassle, fully automatic.
An important rule: No single method fits every scenario on its own. Production environments usually use multiple methods together in layers.

Method 1: Logical Backup with mongodump

This is the most common method and the most suitable one to start with. The mongodump tool connects to your running database and exports the data into files in BSON format; mongorestore then restores these files. You can back up the entire server, a single database, or even a single collection.

Installing the Tools

mongodump and mongorestore come with MongoDB’s “Database Tools” package. You can download and install the version suitable for your operating system from the official MongoDB site.

MongoDB backup — image 2
Downloading the MongoDB Database Tools package from the official site

Basic Backup Command

To take a backup in its simplest form:

mongodump --uri="mongodb://localhost:27017" --out=/yedek/20260608

When the command runs, separate folders and BSON files are created under the folder you specified, one for each database.

Production note: The example above is for an unauthenticated local connection. In production, connect with authentication: --username USER --password PASS --authenticationDatabase admin.
MongoDB backup — image 3
Running the mongodump command
MongoDB backup — image 4
BSON files created under the backup folder for each database

–oplog for a Consistent Backup

If your database is actively receiving writes during the backup (for example, a replica set), it is recommended to use the --oplog option so the backup is consistent. This option also captures the changes that arrive while the backup is running and enables point-in-time recovery:

mongodump --oplog --gzip --out=/yedek/tam

--gzip compresses the backup to save space.

Note: --oplog works only on a full-server dump (all databases); it cannot be combined with a single --db.

Restoring

To restore the backup, mongorestore is used:

mongorestore --drop --oplogReplay /yedek/tam

--drop clears the existing collections before restoring, providing a clean state.

MongoDB backup — image 5
Restoring with mongorestore

For Those Who Prefer a GUI: MongoDB Compass

For those who would rather not deal with the command line, MongoDB’s official graphical interface MongoDB Compass lets you view collections visually and export data in JSON format. However, Compass is not a full backup tool; it provides a collection-based export (indexes and the full database structure are not included in this export). For a real backup, mongodump should be preferred.

MongoDB backup — image 6
Exporting a collection from the MongoDB Compass interface
Pros: Portable, selective (you can even take a single collection), compatible across different MongoDB versions.
Cons: Slow on large databases. On the same data set, the snapshot method takes 3-5 minutes while mongodump can take much longer.

That’s why logical backup is ideal for small and medium-sized deployments.

Method 2: Filesystem Snapshots (Physical Backup)

As your database grows (hundreds of GB and above), mongodump becomes slow. This is where filesystem snapshots come into play. This “block-level” method takes a direct copy of the disk hosting MongoDB’s data files using system tools (for example, LVM on Linux).

Snapshots complete very quickly and run reliably; however, they require additional system configuration beyond MongoDB. The restore also finishes within minutes — which is why this is the most practical method for large databases.

MongoDB backup — image 7
A filesystem snapshot with Linux LVM

Restoring from a Snapshot

In case of a problem, you can roll the database back to the moment the snapshot was taken by merging the snapshot back into the main volume. On Linux/LVM, the flow is three steps:

# 1. Stop the MongoDB service
systemctl stop mongod

# 2. Merge the snapshot back into the main volume (rolls back to the snapshot point)
lvconvert --merge /dev/vg0/mongo_snap

# 3. Start the MongoDB service
systemctl start mongod
LVM snapshot restore
Merging the snapshot back into the main volume with lvconvert –merge (Merged: 100%)
Pros: Very fast, efficient on large data.
Cons: Requires setup and configuration knowledge; replica sets and sharded clusters need extra steps for consistency.

Method 3: Third-Party Backup Tools

For teams that don’t want to deal with the backup job or that manage large/distributed (sharded cluster) deployments, third-party tools make the job easier.

If you want to stay on your own infrastructure, Percona Backup for MongoDB (PBM) is a powerful open-source solution; with compression, physical backup, and sharded cluster support, it is suitable for large deployments.

Pros: Open-source and free, automatic scheduling, manages the complexity of a sharded cluster for you.
Cons: Requires setup and configuration knowledge; maintenance is up to you.

Which Method Should I Choose?

A quick guide:

  • Small database / single server: mongodump is enough and the easiest.
  • Large database (hundreds of GB+): Filesystem snapshots.
  • Distributed / sharded cluster: Third-party tools (e.g., PBM).

Automating Backups

Manual backup is sooner or later forgotten. The healthiest approach is to tie the backup to a scheduled task.

Linux (cron) — every night at 02:00:

0 2 * * * mongodump --oplog --gzip --out=/yedek/mongo_$(date +\%F)

Example .bat file for Windows (Task Scheduler):

@echo off
set TARIH=%date:~-4%-%date:~3,2%-%date:~0,2%
mongodump --uri="mongodb://localhost:27017" --gzip --out=C:\yedek\mongo_%TARIH%

Since the date is added to the folder name, each backup is kept separately. You can run this .bat file every night at a specific time with Task Scheduler.

Whichever Method You Choose: 5 Golden Rules

  1. Apply the 3-2-1 rule: Keep 3 copies of your data, on 2 different storage types, with 1 copy off-site.
  2. Test your backup: A backup that has never been restored is really just an assumption. Practice your restore procedure regularly.
  3. Automate it: Manual backups sooner or later fail because of human error. Automate them with scheduled tasks.
  4. Encrypt and restrict access: Backups are a full copy of your production data; they must be protected with the same security rigor.
  5. Distribute the load: If possible, take the backup not from the primary but from a secondary member of the replica set.

Store Your Backups Safely: Narbulut

Taking your MongoDB backups is only half the story. The real question is: where and how safely are you storing those backups? A backup sitting on the same server disappears together with the data if the server crashes.

Narbulut‘s cloud backup and storage solutions let you store the MongoDB backups you take locally in a secure, encrypted, and geographically separate cloud environment — meaning they handle that critical “off-site copy” part of the 3-2-1 rule for you. With automatic upload, version tracking, and PDPL-compliant infrastructure, your data always stays accessible during disasters such as ransomware and hardware failure.

Store Your Data in the Right Place

Storing those backups in the right place is just as important as taking them. To move your MongoDB backups to a secure cloud layer, start with Narbulut and keep your data safe.

Explore the MongoDB Backup Solution

Leave a Comment

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

Narbulut Product Analysis

Step 1/12
What area of technological improvement are you planning for your company?
Data Security & BackupRansomware, deleted files and disaster recovery.
Cloud Server (IaaS)Website, ERP, CRM or application hosting.
Team CollaborationSecure file sharing and remote work.
Object Storage (S3)Object Storage for developers.
What industry does your company operate in?
Healthcare / MedicalPatient data (GDPR critical).
Finance / AccountingSensitive financial data.
Manufacturing / EngineeringCAD drawings and production plans.
Other / General ServicesOffice documents and general data.
What type of devices need to be protected?
Employee ComputersLaptop and desktop end-user devices.
Physical / Virtual ServersDatabase, Active Directory or File Server.
What should your backup strategy be?
File & Folder BasedOnly important business files (XLS, PDF, SQL) should be backed up.
Full Disk ImageBack up "Everything" including the operating system.
What is your upload speed for cloud backup?
Fiber / High SpeedI can send large data quickly.
Standard / ADSLMy speed is limited, compression is important.
Is ransomware a threat?
Yes, Very CriticalWe have experienced it before or are at risk.
Standard Protection is SufficientBasic backup measures are enough.
How long would you like to keep versions?
90
30 - 90 DaysTo fix recent errors.
365+
1 Year and AboveLegal requirements or archiving.
What will be the primary purpose of the server?
E-Commerce / WebsiteHigh uptime and speed required.
ERP / Accounting SoftwareDatabase performance is important.
Software DevelopmentFlexible resource management.
What infrastructure do you need?
Windows ServerASP.NET, MSSQL, RDP.
Linux (Ubuntu/CentOS)PHP, Python, MySQL, Docker.
What is the estimated user traffic?
Low / MediumEntry level or new project.
High TrafficHeavy campaigns or many users.
Who will manage the server?
I Will Manage ItI have a technical team, root access is enough.
I Need SupportManaged Services required.
How many people will work in the shared workspace?
1 - 10 UsersSmall teams.
10 - 50+ UsersDepartment-based permissions required.
Is remote access required?
Yes, DefinitelyField team needs to upload files from mobile.
No, Office OnlyAccess only from company computers.
Analyzing Your Responses...
BEST SOLUTION FOR YOU

Product Title

Description

Explore Product Now

Product Information Request

Fill out the form so our solution experts can contact you.

Size uygun Narbulut Cloud Server planlarına göz atın

Narbulut Cloud Server ile ihtiyaçlarınıza en uygun sunucuları yapılandırın.

    SUNUCU TEKLİF & YAPILANDIRMA FORMU

    1. KURUMSAL KİMLİK & İLETİŞİM
    2. TEKNİK GEREKSİNİMLER
    3. LİSANS YÖNETİMİ

    Check out Narbulut Cloud Server plans that suit you

    Configure the servers that best fit your needs with Narbulut Cloud Server.

      SERVER QUOTE & CONFIGURATION FORM

      1. CORPORATE IDENTITY & CONTACT
      2. TECHNICAL REQUIREMENTS
      3. LICENSE MANAGEMENT

      Narbulut Mobile’ı İndirin

      Uygulamayı indirmek istediğiniz platformu seçin

      Download Narbulut Mobile

      Select the platform you want to download the app

      ×