a full stack enthusiast interested in Javascript / Typescript / Kotlin / Python / React / React Native / (Android & iOS) native / Cloud


How to dump remote dokku-mongodb and restore local instance

I have a side project using dokku, it works well. But then I want to dump the production data to local in order to test some cases. I thought it should be as simple as dump and restore, but I was wrong. It took me a while, I think write it down might help someone else or future me.

1 Dump the database on the server

dokku mongo:export mongo_service_name > data.dump.gz

2 Download to your local machine

scp root@ ~/

3 Restore

mongorestore --host localhost:27017 --gzip --archive=data.dump.gz --db mongo_service_name

The tricky part is the name after --db, should match the database name in your dump file.

4 End

That’s all. Hope it helps.

Thanks for reading!

Follow me (albertgao) on twitter, if you want to hear more about my interesting ideas.