Skip to content

Instantly share code, notes, and snippets.

@jayjariwala
Last active January 4, 2018 19:24
Show Gist options
  • Save jayjariwala/5fdabef00c0fb0d187a1405c1d4c29a8 to your computer and use it in GitHub Desktop.
Save jayjariwala/5fdabef00c0fb0d187a1405c1d4c29a8 to your computer and use it in GitHub Desktop.
Mongodb Import and export commands
#Import into database
sudo mongoimport --db newdb --collection restaurants --file primer-dataset.json
#export database collection
sudo mongoexport --db newdb -c restaurants --out newdbexport.json
# Take backup
create a folder regular backup folder
sudo mkdir /var/backups/mongobackups
Backup of the database
sudo mongodump --db newdb --out /var/backups/mongobackups/`date +"%m-%d-%y"`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment