How to back up a MongoDB database, step by step
Updated 10/23/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 pricingRelated tutorials
Automated database backups with Portabase and a Storage Box
Set up Portabase to back up your databases and push the copies to a cloudlinux.ro Storage Box, in a separate location.
Updated 10/23/2026BackupHow to back up a WordPress site, step by step
A complete WordPress backup: the files (wp-content) and the database, plus how to send it all to a Backup Box mounted as an extra disk.
Updated 10/23/2026BackupHow to mount a Backup Box on Windows and share it with users
Mount a Backup Box as a network drive on Windows via SMB and share it with your team: common storage, accessible like a normal disk.
Updated 10/23/2026