Sha256: 35f23574bcc191624fe74df964c3a0f8e20940280f272711ade413ed53a3570d

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

module Dumper
  module Database
    class Redis < Base
      DUMP_TOOL = 'redis-cli'
      FORMAT = 'rdb'

      def command
        uncompressed = filename.sub('.gz','')
        "cd #{tmpdir} && cp #{@config[:dbpath]} #{uncompressed} && gzip #{uncompressed}"
      end

      def set_config_for(rails_env=nil)
        return unless defined?(::Redis) &&
          (main_thread_redis = find_instance_in_object_space(::Redis))

        client = main_thread_redis.client

        # New connection for the agent thread
        redis = ::Redis.new(:host => client.host, :port => client.port, :password => client.password, :db => client.db)
        dir         = redis.config(:get, :dir)['dir']
        dbfilename  = redis.config(:get, :dbfilename)['dbfilename']
        dbpath = "#{dir}/#{dbfilename}"

        return unless File.exist?(dbpath) # Redis must run on the back up node

        @config = {
          :host => client.host,
          :port => client.port,
          :password => client.password,
          :database => client.db,
          :dump_tool => dump_tool_path,
          :dbpath => dbpath
        }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dumper-1.7.2 lib/dumper/database/redis.rb
dumper-1.7.1 lib/dumper/database/redis.rb
dumper-1.7.0 lib/dumper/database/redis.rb
dumper-1.6.1 lib/dumper/database/redis.rb
dumper-1.6.0 lib/dumper/database/redis.rb