Backup and Restore MongoDb
Backup using mongodump
1) lets make a directory to dump our mongo db into
mkdir mongdump
2) lets backup into the mongdump folder
mongodump -h localhost:27017 -d dbname -o location/to/mongdump
replace "dbname" with the name of the database
3) go into the mongdump folder to verify the backup is there, the back file will have the .bson extension
Restore using mongorestore
mongorestore --drop -d dbname /location/to/mongdump/dbname
dbname should be replace by the name of your database. Also when you did a mongodump into the folder mongdump most likely a subfolder with the db name was created, hence the /location/to/mongdump/dbname
. you always want to point to the folder that contains the .BSON files
Written by Saad Shamim
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mongodb
Authors
dominikgarber
81.15K
sativaware
80.22K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#