Mongo Database Prod & Dev - Copy

Hey all,

Wondering if anyone has a current script for managing mongo I could just copy & learn from.

I want to be able to run a script to clone my prod dbase into the meteor mongo environment so that I can use real data and be destructive in my app (if required) without impacting prod data.

I know it shouldn’t be too hard to do in bash, but rather than re-invent the wheel I am sure someone her has a tool they could share…


I’m using a good app to manage Mongo, it can do also copy/paste of the whole database, between hosts.

You can also use cli to do backup:

    docker exec -it mongodb mongodump
    docker cp mongodb:/dump mongodump

and restore

    docker cp mongodump/[database name directory] mongodb:/dump
    docker exec -it mongodb mongorestore -d [database name] dump/[database name directory]

I’m also using the paid version of NoSQLBooster.

It is really well done with many features, backup/restore and moving data round are very simple with this tool.

I can say that a simple script calling mongodump and mongorestore with pre-configured options (e.g., listed environments) is great. It depends on the workflow, but sometimes you’ll need to download staging/test DB as well.

When working with multi-tenant systems it’s important to be able to fetch only a relevant part of the DB, e.g., all data related to tenants X, Y, and Z. In our case, the script has a list of collection/query type pairs.

1 Like

Thanks guys. I think what @radekmie said is all I need to do.

I’ve installed nosqlclient for when I need to perform manual database management stuff, but that is running in its own docker container pointing to my mongo environment which is in another container.
My meteor environment is running inside a separate container for hosted VSCode (codercom/code server). I don’t want to have to work out how to expose that meteor mongo database to nosqlclient or anything else on the host.

I can just write a script to run on the VSCode container which will do the pull from the remote database (which it can do because it’s exposed to the network) and replace the development database with that.

I was just hoping to get a look at a current script someone has. This is what I was looking at but its all for VERY old meteor projects back when Meteor hosted your app and database for free.