MongoDB migration command line tools for dump restore export and import databases
You should have rsync
installed on you machine
# on windows with chocolatey
choco install rsync
Also the binary of mongodump
and mongorestore
must be present in your path.
Then if you need to access MongoDb into a Remote Machine, make sure you have set up an SSH key on the server.
Bored to dump, restore or copy collections between different environments?
m-mongo
is here to help with these frequent operations.
Let's start by installing it:
npm i -g @tonillo/m-mongo
# or with yarn
yarn global install @tonillo/m-mongo
Now open a terminal or prompt and type m-mongo
.
We can set up an optional folder where dumps are stored, otherwise by default the dump files will be stored in the current folder.
We can now add a cluster.
All the information that you are inserting, are stored in a json file under ~/.config/configstore/m-mongo.json
.
Now we can make a dump.
Finally we can restore the dump.
export DEBUG='*'
This project is created with typescript-starter.
I was inspired by this Sitepoint project, with this usefult Sitepoint article