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

Instance Method Summary collapse

Methods included from Configuration::Helpers

included

Constructor Details

#initialize(model, &block) ⇒ Redis

Creates a new instance of the Redis database object



39
40
41
42
43
44
45
46
47
48
# File 'lib/backup/database/redis.rb', line 39

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

  @additional_options ||= Array.new

  instance_eval(&block) if block_given?

  @name ||= 'dump'
  @redis_cli_utility ||= utility('redis-cli')
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backup::Configuration::Helpers

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



17
18
19
# File 'lib/backup/database/redis.rb', line 17

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



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

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



17
18
19
# File 'lib/backup/database/redis.rb', line 17

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



17
18
19
# File 'lib/backup/database/redis.rb', line 17

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



56
57
58
59
60
61
# File 'lib/backup/database/redis.rb', line 56

def perform!
  super

  invoke_save! if invoke_save
  copy!
end