Question

This post is about backing up your meteor database

I am trying to back up my meteor database and I understand what this post is telling me to do, but I must not be in the right directory when I run the mongodump command, b/c I keep getting 'Command not found'. Or do I need to export a path?


[EDIT]

OK, now I have the binaries installed but when I run 'mongodump', I get:

couldn't connect to [127.0.0.1] couldn't connect to server 127.0.0.1:27017

... and when I run 'mongodump --host localhost:3002', I get:

couldn't connect to [localhost:3002] couldn't connect to server localhost:3002

Now what?

Was it helpful?

Solution

OK, thanks to @David Weldon, I can provide a fairly complete answer to this issue:

Backing up and restoring your local MongoDB for Meteor users (OSX)

Backup:

1) Your app must be running, so start up your Meteor server.

2) In a terminal window (NOT in the meteor mongo shell), enter: mongodump -h 127.0.0.1 --port 3001 -d meteor

This will create a 'dump' directory inside your home folder (your name under Users).

3) If you get a 'command not found' message, you probably just installed Mongo as a part of Meteor, meaning you don't have the mongo command line tools. Use a package like Homebrew to reinstall Mongo and you will have the command line tools. This will also add the correct PATH information to your system, so that it can find the tools.

Restoring:

1) From MiniMongo shell (run ‘meteor mongo’ inside your Meteor project dir), enter:

db.[collectionName].drop(); //repeat for all collections you wish to restore

2) Then, from a terminal window, enter:

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

Caveats:

The individual documents will not necessarily be in the same order after they are restored. So you need some way to sort documents that need to be presented in a certain order.

OTHER TIPS

Caveats:

The individual documents will not necessarily be in the same order after they are restored. So you need some way to sort documents that need to be presented in a certain order.

There is a flag for this mongorestore --maintainInsertionOrder

If you are restoring to a mup'ed meteor app, the command would be:

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

If you forgot the name of your app, you can see it by going into the mongo shell and listing all databases.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top