19 Jul 2014, 9:21pm
uncategorized

leave a comment




  • Anzeige
  • Copying MongoDB from meteor.com

    I started deploy­ing my lat­est Meteor app umeedoo.net to my own VPS and wanted to use the data from my beta sys­tem hosted at umeedoo.meteor.com.
    First of all, I was sur­prised how sim­ple and easy it was to deploy using Meteor Up (MUP). Some weeks before, I spend an entire day on installing the Meteor envi­ron­ment on a Debian machine — now it’s less than 15 min­utes! One caveat though, it did not work for me on Debian, I had to drop my pre­vi­ous 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, dif­fer­ent story, but a biiig thanks to Arun­oda for the great work on MUP!!

    So, how to db.copyDatabase(); the data from the orig­i­nal DB to yours?

    The method sig­na­ture 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 sim­plic­ity.
    Gen­eral approach: get the Mon­goDB URL, extract all the para­me­ters above, log into your own Mon­goDB instal­la­tion and use db.CopyDatabase(); to move the data over.

    All com­mands need to be exe­cuted on the same machine. (FYI, the user­name and pass­word get auto­mat­i­cally gen­er­ated and it did not work to get the URL on my machine and use the user­name and pass­word on the server… strange though)
    Thus, install Meteor on your server curl https://install.meteor.com/ | sh.
    Then, get the Mon­goDB URL meteor mongo --url app.meteor.com
    It will look like this mongodb://client-fd532e7d:683a9a4e-1604-5729-07fd-df1ba7dcbbf9@production-db-a2.meteor.io:27017/app_meteor_com
    The parts are

    • user­name: client-fd532e7d
    • pass­word: 683a9a4e-1604-5729-07fd-df1ba7dcbbf9
    • meteor-mongo-domain: production-db-a2.meteor.io:27017

    Start a Mon­goDB CLI by typ­ing mongo.
    In my case, the data­base cre­ated by the app and MUP was called “admin” (i.e. [your-db-name]=“admin”). How to find yours? Use “show dbs” in the Mon­goDB 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 sec­onds.
    When I tried first, I got an error about a dupli­cate key (the deployed app had cre­ated some data already), drop­ping the entire DB fixed it. Also, the user­name and pass­word are valid for a short time only, so maybe hav­ing to ter­mi­nals open is a good idea.

    Ref­er­ences: Cloning Mon­goDB, Meteor dump, Clone DB from meteor.com, Copy DB from one server to another

    *name

    *e-mail

    web site

    leave a comment