Restore my local mongodb on *.meteor.com


#1

Is it possible to restore my local mongodb on *.meteor.com test deployment site?
I backed it up using mongodump, but I couldn’t find any reference about restoring it on myapp.meteor.com.
I guess it’s not possible. Am I right?


#2

It used to be possible. I haven’t tried it for a while, but here’s what used to work.

In the terminal, type:

meteor mongo www.myAppName.com --url

The www.myAppName.com is because I’m pointing my domain name at Meteor’s servers. If you’ve just deployed to meteor.com directly it would just be myAppName (only with your app name :grinning: ).

Result:

mongodb://client-5245f5b7:e25dfa67-cd86-553f-e915-f3d392bcc9e1@production-db-c3.meteor.io:27017/www_myappname_com

Take the details from that (client, password, db name) and substitute them into the command below:

mongorestore -u client-5245f5b7 -p e25dfa67-cd86-553f-e915-f3d392bcc9e1 -h production-db-c3.meteor.io:27017 -db www_myappname_com -drop

Notes:

  • I was in a directory with a sub-directory called “dump” that contained the mongodb bson files when I ran this command, which is why there isn’t a path at the end of the command.
  • I used the -drop flag because I wanted to overwrite the existing data in the meteor.com database
  • You have 1 minute to fire off that mongorestore command after getting the details from the previous command. After that your change will get rejected (“auth fails”).

Some people much cleverer than me came up with this, which is very cool, saving you from the big cut-and-paste-race-against-the-clock:

CMD=`meteor mongo -U www.myappname.com | tail -1 | sed 's_mongodb://\([a-z0-9\-]*\):\([a-f0-9\-]*\)@\(.*\)/\(.*\)_mongorestore -u \1 -p \2 -h \3 -d \4_'`
echo $CMD

Replace echo $CMD with:

$CMD /path/to/dump

to actually restore the dump to the meteor.com servers.


#3

Hi,

Just want to share my experience. I found out that the easiest way to do is to use NoSQL Manager for MongoDB. I just copy paste my Database from local server to production server.

Kosona


#4

How does this work with apps deployed to *.meteor.com where the meteor deploy process is handling database setup and maintenance?


#5

For me, in production you should use a separate MongoDB. The MongoDB include with meteor is for development only.

Kosona


#6

I’d argue that the whole *.meteor.com setup is really just for development, but that’s what the OP was asking about.