DEV Community

Wai Liu
Wai Liu

Posted on • Originally published at waiholiu.blogspot.com on

Super quick way to back up and restore a Meteor Mongodb database

If you're ever planning on doing anything experimental in your Meteor solution and don't want to be corrupting your existing data, here is a quick way to back it all up and restore it.

Firstly, you can't use the Meteor mongo command line as Mongodump doesn't exist there, so you must install the full Mongodb tool set on your machine. I just used brew to install on my Mac but instructions are at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/

To backup, just execute this command

mongodump -h 127.0.0.1 --port 3001 -d

This puts the backup inside the folder dump/ relative to the folder you ran the command in. Generally I like to put it in the folder as my app solution.

To restore back to the state of the last backup, just execute this command

mongorestore -h 127.0.0.1 --port 3001 -d meteor --drop dump/

Changing the database name, this allows you to have multiple backups too.

Top comments (0)