Sha256: 1c41866d0a6b1315c81dfef2b8f371708ab0d6a77084bcdb29f43ed38f0d76f5

Contents?: true

Size: 818 Bytes

Versions: 4

Compression:

Stored size: 818 Bytes

Contents

if File.exist? Rails.root.join('config/mongoid.yml')
  namespace :mongodb do
    config = YAML.load(File.read(Rails.root.join('config/mongoid.yml')))[Rails.env.to_s]['sessions']['default']
    db = config['database']
    host = config['hosts'][0].split(':')[0]
    port = config['hosts'][0].split(':')[1]
    
    backup = "mongodump --host #{host} --port #{port} --db #{db}"
    desc backup
    task :dump do
      zfben_rails_rake_system backup
    end

    restore = "mongorestore --host #{host} --port #{port}"
    desc restore
    task :restore do
      zfben_rails_rake_system restore
    end
    
    repair = "mongod --nohttpinterface --nojournal --port #{port} --bind_ip #{host} --dbpath #{Rails.root}/mongo --repair"
    desc repair
    task :repair do
      zfben_rails_rake_system repair
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
h2ocube_rails_tasks-0.0.6 lib/h2ocube_rails_tasks/tasks/mongodb.rb
h2ocube_rails_tasks-0.0.5 lib/h2ocube_rails_tasks/tasks/mongodb.rb
h2ocube_rails_tasks-0.0.4 lib/h2ocube_rails_tasks/tasks/mongodb.rb
h2ocube_rails_tasks-0.0.3 lib/h2ocube_rails_tasks/tasks/mongodb.rb