Posts

Showing posts with the label Mongo

Mongorestore using knife

This post is a continuation to my post Taking a Mongodump using Knife . Keeping the assumptions the same as the previous post, this post outlines a knife plugin to restore your mongo database from a dump taken as above. module KnifePlugins   class MongoDumpApply < Chef::Knife     banner 'knife mongo dump apply'         option :db_env,       :long => '--db-env DB_ENV',       :description => 'Environment to apply the dump to'      option :dump_dir,       :long => '--dump-dir DUMP_DIR',       :description => 'Full path to dump location'    deps do       require 'chef/search/query'    end     def run       @dump_dir = config[:dump_dir]       @env = config[:db_env]      if !vali...

Mongodump and upload to S3 using knife

Quite recently I have had to write a knife plugin to take mongo dumps. This post contains the code for the same with a few assumptions in place. Assumptions: 1.  CentOS 6.3, mongo db version 2.4.1 2.  Chef environment has the db config as below :      override_attributes({ database:  { user: 'db_user',                  dump_dir: '/opt/mongodb-dump',                  auth: true,                  replica: {                         id: 'rsTest',                         mongo_primary:'x.x...