Is there a simple way to export the data from a meteor deployed app?
To get the URL for your deployed site at meteor.com use the command (you may need to provide your site password if you password protected it):
meteor mongo --url YOURSITE.meteor.com
Which will return something like :
mongodb://client:PASSWORD@sky.member1.mongolayer.com:27017/YOURSITE_meteor_com
Which you can give to a program like mongodump
mongodump -u client -h sky.member1.mongolayer.com:27017 -d YOURSITE_meteor_com\ -p PASSWORD
The password is only good for one minute. For usage:
$ meteor --help mongo
And here's how to do the opposite: (uploading your local monogo db to meteor)
https://gist.github.com/IslamMagdy/5519514
# How to upload local db to meteor:# -h = host, -d = database name, -o = dump folder namemongodump -h 127.0.0.1:3002 -d meteor -o meteor# get meteor db url, username, and passwordmeteor mongo --url myapp.meteor.com# -h = host, -d = database name (app domain), -p = password, folder = the path to the dumped dbmongorestore -u client -h c0.meteor.m0.mongolayer.com:27017 -d myapp_meteor_com -p 'password' folder/
Based on Kasper Souren's solution I created an updated script that works with current versions of Meteor and also works when you protect your remote Meteor app with a password.
Please create the following script parse-mongo-url.coffee
:
spawn = require('child_process').spawnmongo = spawn 'meteor', ['mongo', '--url', 'YOURPROJECT.meteor.com'], stdio: [process.stdin, 'pipe', process.stderr]mongo.stdout.on 'data', (data) -> data = data.toString() m = data.match /mongodb:\/\/([^:]+):([^@]+)@([^:]+):27017\/([^\/]+)/ if m? process.stdout.write "-u #{m[1]} -p #{m[2]} -h #{m[3]} -d #{m[4]}" else if data == 'Password: ' process.stderr.write data
Then execute it like this in a *nix shell:
mongodump `coffee parse-mongo-url.coffee`