Class: Backup::Database::Redis

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/database/redis.rb

Constant Summary

Constants included from CLI::Helpers

CLI::Helpers::UTILITY

Instance Attribute Summary collapse

Attributes inherited from Base

#utility_path

Instance Method Summary collapse

Methods included from Configuration::Helpers

#clear_defaults!, #load_defaults!

Methods included from CLI::Helpers

#command_name, #raise_if_command_failed!, #run, #utility

Constructor Details

#initialize(model, &block) ⇒ Redis

Creates a new instance of the Redis database object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/backup/database/redis.rb', line 35

def initialize(model, &block)
  super(model)

  @additional_options ||= Array.new

  instance_eval(&block) if block_given?

  @name ||= 'dump'

  if @utility_path
    Logger.warn "[DEPRECATED] " +
      "Database::Redis#utility_path has been deprecated.\n" +
      "  Use Database::Redis#redis_cli_utility instead."
    @redis_cli_utility ||= @utility_path
  end
  @redis_cli_utility ||= utility('redis-cli')
end

Instance Attribute Details

#additional_optionsObject

Additional “redis-cli” options



27
28
29
# File 'lib/backup/database/redis.rb', line 27

def additional_options
  @additional_options
end

#hostObject

Connectivity options



23
24
25
# File 'lib/backup/database/redis.rb', line 23

def host
  @host
end

#invoke_saveObject

Determines whether Backup should invoke the SAVE command through the ‘redis-cli’ utility to persist the most recent data before copying over the dump file



19
20
21
# File 'lib/backup/database/redis.rb', line 19

def invoke_save
  @invoke_save
end

#nameObject

Name of and path to the database that needs to get dumped



9
10
11
# File 'lib/backup/database/redis.rb', line 9

def name
  @name
end

#passwordObject

Credentials for the specified database



13
14
15
# File 'lib/backup/database/redis.rb', line 13

def password
  @password
end

#pathObject

Name of and path to the database that needs to get dumped



9
10
11
# File 'lib/backup/database/redis.rb', line 9

def path
  @path
end

#portObject

Connectivity options



23
24
25
# File 'lib/backup/database/redis.rb', line 23

def port
  @port
end

#redis_cli_utilityObject

Path to the redis-cli utility (optional)



31
32
33
# File 'lib/backup/database/redis.rb', line 31

def redis_cli_utility
  @redis_cli_utility
end

#socketObject

Connectivity options



23
24
25
# File 'lib/backup/database/redis.rb', line 23

def socket
  @socket
end

Instance Method Details

#perform!Object

Performs the Redis backup by using the ‘cp’ unix utility to copy the persisted Redis dump file to the Backup archive. Additionally, when ‘invoke_save’ is set to true, it’ll tell the Redis server to persist the current state to the dump file before copying the dump to get the most recent updates in to the backup



59
60
61
62
63
64
# File 'lib/backup/database/redis.rb', line 59

def perform!
  super

  invoke_save! if invoke_save
  copy!
end