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:
MongoDB backup with mongodump
We are going to see how to backup our MongoDB database, using mongodump. mongodump allows you to create backups from standalone, replica sets or sharded cluster deployments.
From MongoDB server 4.4, you need to install the
mongodumputility separately. Read more at the MongoDB database tools docs
Backup a MongoDB standalone instance
The command to backup a simple MongoDB standalone instance is of the format:
mongodump <options> <connection-string>Running
mongodumpalone from the command line without any options will assume the database is located onlocalhostat port27017with no authentication.When the backup is completed, a
/dumpdirectory is created.
Backup a remote MongoDB instance
Backing up a remote MongoDB instance can be done with the following command:
mongodump --uri="mongodb://<host URL/IP>:<Port>" [additional options]See more options and how to use mongodump on MongoDB database tools docs.
You should see something like the image below when the command is running:

MongoDB Restore with mongorestore
After backing up your instance, you may need to restore the data at some time. That can be done using mongorestore. mongorestore allows you to load data from either a binary database dump created by mongodump or the standard input into the MongoDB instance.
Make sure you first drop any existing Rocket.Chat schema in your database with the same name as the one you are restoring.
The syntax for the
mongorestorecommand is as follows:
mongorestore <options> <connection-string> <directory or file to restore>The simple command below restores from a
dumpdirectory to a localmongodinstance running on port27017:
mongorestore dump/You can restore to a remote instance by running the following command:
mongorestore --uri="mongodb://<host URL/IP>:<Port>" /dumpYou have the ability to also restore a specific collection or collections from the
dump/directory. See MongoDB docs
In a successful command execution, you should see a screen like the one below:
