I started deploying my latest Meteor app umeedoo.net to my own VPS and wanted to use the data from my beta system hosted at umeedoo.meteor.com.
First of all, I was surprised how simple and easy it was to deploy using Meteor Up (MUP). Some weeks before, I spend an entire day on installing the Meteor environment on a Debian machine – now it’s less than 15 minutes! One caveat though, it did not work for me on Debian, I had to drop my previous Debian VM and replaced it with Ubuntu as MUP depends on Upstart and it seems rather tricky to replace Debian’s SysVinit with Upstart. Ok, different story, but a biiig thanks to Arunoda for the great work on MUP!!
So, how to db.copyDatabase(); the data from the original DB to yours?
The method signature is
db.copyDatabase("[app-name]_meteor_com", "[your-db-name]", "[meteor-mongo-domain]", "[username]", "[password]");
I’ll assume “app” to be the app name for simplicity.
General approach: get the MongoDB URL, extract all the parameters above, log into your own MongoDB installation and use db.CopyDatabase(); to move the data over.
All commands need to be executed on the same machine. (FYI, the username and password get automatically generated and it did not work to get the URL on my machine and use the username and password on the server… strange though)
Thus, install Meteor on your server
curl https://install.meteor.com/ | sh.
Then, get the MongoDB URL
meteor mongo --url app.meteor.com
It will look like this
The parts are
Start a MongoDB CLI by typing
In my case, the database created by the app and MUP was called “admin” (i.e. [your-db-name]=”admin”). How to find yours? Use “show dbs” in the MongoDB CLI to see which one is yours.
Then write “use [your-db-name]” to switch to your DB.
And finally, using the data from above:
db.copyDatabase("app_meteor_com", "admin", "production-db-a2.meteor.io:27017", "client-2fbeb6ef", "1bd44ece-b3fa-7d1b-0046-83b917927f35"); will copy the data over in a few seconds.
When I tried first, I got an error about a duplicate key (the deployed app had created some data already), dropping the entire DB fixed it. Also, the username and password are valid for a short time only, so maybe having to terminals open is a good idea.