MongoDB Backup and Restore
Last updated
Last updated
Maintaining backups of your workspace data is a very important practice. These data backups can act as a safety measure where data can be recovered or restored in case of an emergency.
Rocket.Chat uses MongoDB as its database. With MongoDB, you have multiple built-in backup options depending on the deployment method.
In this guide, we are going to focus on how to:
mongodump
We are going to see how to backup our MongoDB database, using . mongodump
allows you to create backups from standalone, replica sets or sharded cluster deployments.
The command to backup a simple MongoDB standalone instance is of the format:
Running mongodump
alone from the command line without any options will assume the database is located on localhost
at port 27017
with no authentication.
When the backup is completed, a /dump
directory is created.
Backing up a remote MongoDB instance can be done with the following command:
You should see something like the image below when the command is running:
mongorestore
The syntax for the mongorestore
command is as follows:
You can restore to a remote instance by running the following command:
In a successful command execution, you should see a screen like the one below:
See more options and how to use mongodump
on .
After backing up your instance, you may need to restore the data at some time. That can be done using . mongorestore
allows you to load data from either a binary database dump created by or the standard input into the MongoDB instance.
The simple command below restores from a dump
directory to a local instance running on port 27017
:
You have the ability to also restore a specific collection or collections from the dump/
directory.