Skip to content

Instantly share code, notes, and snippets.

@abhishekdgeek
Created March 9, 2016 09:15
Show Gist options
  • Save abhishekdgeek/501f4832e939c14e46f1 to your computer and use it in GitHub Desktop.
Save abhishekdgeek/501f4832e939c14e46f1 to your computer and use it in GitHub Desktop.
Simple mongo db dumping shell script. Used BSON for more information and accuracy.
#!/bin/bash
# MongoDB Backup Script
NOW=$(date +"%m-%d-%Y-%H-%M")
NAME="backup.$NOW"
DB="mean-dev"
SERVER="localhost"
PORT="27017"
mongodump --host $SERVER -d $DB --port $PORT --out $NAME
tar -cvf $NAME.tar $NAME/
rm -r $NAME
gzip $NAME.tar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment