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 [email protected]:data.dump.gz ~/
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.
See our article about the fastest way to convert binary into decimal using a table.
