Docker Mongo Backup and Restore
This guide shows how you can perform backup and restore of your Rocket.Chat's mongo database in docker.
To back up your MongoDB database in docker follow these steps:
- Run the following command on your terminal to list out the label of the container running mongo
docker ps -a
You see a list of containers running, note the name of the mongo container in this case
List of running docker containers
- Run this to dump the database into a binary file
docker exec <database_name> sh -c 'mongodump --archive' > db.dump
When successful, you should see
db.dumpfile in the current directory.
To restore the backup, run the following command
docker exec -i <database_name> sh -c 'mongorestore --archive' < db.dump