Migration of MongoDB database is part and parcel of DevOps, especially when you are running your own projects.
MongoDB provides us with two utilities for performing database migration – mongodump
and mongorestore
.
A simple MongoDB database migration can be performed in 5 steps:
-
Use the
mongodump
command to export the data of a MongoDB database instance as files in the source server’s filesystem.
- Use the
tar
command to compress the exported files as a single .tar.gz
file in the source server’s filesystem.
- Use the
scp
command to send the .tar.gz
file from the source server to the destination server.
- Use the
tar
command to decompress the .tar.gz
file at the destination server.
- Use the
mongorestore
to import the extracted files into the destination MongoDB database.
This post discusses how you can perform MongoDB database migration with utilities provided by MongoDB and most Linux servers.
Follow us