Sync Local and Production MongoDB Data
Start by cloning the mongo-sync
on your machine:
git clone https://github.com/sheharyarn/mongo-sync.git
cd mongo-sync
Edit the provided config.yml
with your db details:
local:
db: 'local_db_name'
remote:
db: 'remote_db_name'
host:
url: 'some.remoteurl.com'
port: 27017
access:
username: 'remote_mongo_user'
password: 'remote_mongo_pass'
# For Heroku MongoDB URLs, here's the legend:
# mongodb://username:password@hosturl.com:port/db_name
Now, you can start syncing your databases:
./mongo-sync push # Push DB to Remote
./mongo-sync pull # Pull DB to Local
Notes:
- The
push
andpull
commands overwrite the target DB
- If you include this script into your project, it's a good idea to add
config.yml
to your.gitignore
<br/>
• mongo-sync on Github
• Original Blog Post
Written by Sheharyar Naseer
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#