CloudLinux.ro
Backup

How to back up a MongoDB database, step by step

Updated 7/20/2026

MongoDB gives you mongodump for compressed, easy-to-restore backups. Here is the full process.

1. Manual backup with mongodump

A single database, compressed into an archive:

mongodump --db mydb --gzip --archive=mydb-$(date +%F).archive

The whole instance:

mongodump --gzip --archive=all-$(date +%F).archive

2. Restore

mongorestore --gzip --archive=mydb-2026-07-18.archive

3. Automate with cron

0 3 * * * mongodump --db mydb --gzip --archive=/mnt/backup/mydb-$(date +\%F).archive

Keep copies on a Backup Box

Mount a Backup Box as an extra disk and write the archives straight there, off-server. The address, username and password are on the Backup Box page in your panel.

Mount as an extra disk (SMB)

apt-get install -y cifs-utils
mkdir -p /mnt/backup
mount -t cifs //BACKUP_BOX_ADDRESS/backup /mnt/backup -o username=USER,password=PASSWORD,vers=3.0

Mount over SFTP (SSHFS)

apt-get install -y sshfs
sshfs -p 22 USER@BACKUP_BOX_ADDRESS:/ /mnt/backup

With backups on the Backup Box, you are protected even if the server fails completely. See also the general backup guide.

Put this guide into practice on your own VPS

EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.

See pricing

Related tutorials