Skip to content

Instantly share code, notes, and snippets.

@mbrowne
Created March 24, 2014 21:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mbrowne/9749944 to your computer and use it in GitHub Desktop.
Save mbrowne/9749944 to your computer and use it in GitHub Desktop.
Shell script to copy remote MongoDB database (and overwrite local copy)
#!/bin/bash
#SYNC MONGODB DATABASE FROM REMOTE SERVER
#NOTE: This overwrites the local copy of the database
remoteHost='yourhost.com'
remoteDbUser='root'
remoteDbPasswd='password123'
remoteDb='test'
localDb='test'
mongo $localDb --eval "db.dropDatabase(); db.copyDatabase('$remoteDb', '$localDb', '$remoteHost', '$remoteDbUser', '$remoteDbPasswd')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment