Skip to content

Instantly share code, notes, and snippets.

@mnlcandelaria
Created November 25, 2015 16:43
Show Gist options
  • Save mnlcandelaria/8c29e3cac0aef3c725f8 to your computer and use it in GitHub Desktop.
Save mnlcandelaria/8c29e3cac0aef3c725f8 to your computer and use it in GitHub Desktop.
Database Dump
#!/bin/bash
HOST="myhost.com"
PORT="1337"
REMOTE_DB="myremote"
LOCAL_DB="mylocal"
USER="giraffe"
PASS="7hIs15MyPa5s"
## DUMP THE REMOTE DB
echo "Dumping '$HOST:$PORT/$REMOTE_DB'..."
mongodump --host $HOST:$PORT --db $REMOTE_DB -u $USER -p $PASS
## RESTORE DUMP DIRECTORY
echo "Restoring to '$LOCAL_DB'..."
mongorestore --db $LOCAL_DB --drop dump/$REMOTE_DB
## REMOVE DUMP FILES
echo "Removing dump files..."
rm -r dump
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment