Sync MongoDB Data Between Development and Production Databases
For a recent project of mine, I had to constantly copy my local MongoDB Database to and from my Production Heroku Database.
mongorestore again and again with complicated flags to support remote urls quickly became a hassle.
I had previously used heroku-mongo-sync, but it is now deprecated in favor of
marcofognog’s fork. Sadly, neither of them worked for me.
So I decided to write my own. Meet mongo-sync.
It’s a simple shell script that allows you to sync your local and remote MongoDB databases, using two commands;
Start by cloning the script on your machine:
Edit the provided
config.yml with your db details:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Now, you can start syncing your databases:
I’m planning to convert it into a Ruby Gem and a Heroku Plugin as well.
Github: sheharyarn / mongo-sync
pullcommands overwrite the target DB
- If you include this script into your project, it’s a good idea to add