How to migrate your MongoDB database instance with mongodump, mongorestore, tar and scp
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
mongodumpcommand to export the data of a MongoDB database instance as files in the source server’s filesystem. - Use the
tarcommand to compress the exported files as a single.tar.gzfile in the source server’s filesystem. - Use the
scpcommand to send the.tar.gzfile from the source server to the destination server. - Use the
tarcommand to decompress the.tar.gzfile at the destination server. - Use the
mongorestoreto 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