Is there a simple way to export the data from a meteor deployed app?

后端 未结 12 2136
轻奢々
轻奢々 2020-11-30 16:30

Is there a simple way to export the data from a meteor deployed app?

So, for example, if I had deployed an app named test.meteor.com...

How could I easily d

12条回答
  •  旧时难觅i
    2020-11-30 17:27

    I made this simple Rakefile to copy the live db to local.

    To restore the live db to my local machine I just do...

    rake copy_live_db
    

    Replace myapp with the name of your meteor.com - e.g myapp.meteor.com.

    require 'rubygems'
    require 'open-uri'
    
    desc "Backup the live db to local ./dump folder"
    task :backup_live_db do
      uri = `meteor mongo myapp --url`
      pass = uri.match(/client:([^@]+)@/)[1]
      puts "Using live db password: #{pass}"
      `mongodump -h meteor.m0.mongolayer.com:27017 -d myapp_meteor_com -u client -p #{pass}`
    end
    
    
    desc "Copy live database to local"
    task :copy_live_db => :backup_live_db do
      server =  `meteor mongo --url`
      uri = URI.parse(server)
      `mongorestore --host #{uri.host} --port #{uri.port} --db meteor --drop dump/myapp_meteor_com/`
    end
    
    desc "Restore last backup"
    task :restore do
      server =  `meteor mongo --url`
      uri = URI.parse(server)
      `mongorestore --host #{uri.host} --port #{uri.port} --db meteor --drop dump/myapp_meteor_com/`
    end
    

提交回复
热议问题