Class: EY::Backup::Engine

Inherits:
Base
  • Object
show all
Includes:
Spawner
Defined in:
lib/ey_backup/engine.rb

Direct Known Subclasses

MysqlEngine, Postgresql

Constant Summary

Constants included from Spawner

Spawner::CHUNK_SIZE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Spawner

#ioify, #run, #runs?, #spawn

Methods inherited from Base

#logger

Constructor Details

#initialize(username, password, host, key_id, force, allow_concurrent, skip_analyze, log_coordinates) ⇒ Engine

Returns a new instance of Engine.



29
30
31
# File 'lib/ey_backup/engine.rb', line 29

def initialize(username, password, host, key_id, force, allow_concurrent, skip_analyze, log_coordinates)
  @username, @password, @host, @key_id, @force, @allow_concurrent, @skip_analyze, @log_coordinates = username, password, host, key_id, force, allow_concurrent, skip_analyze, log_coordinates
end

Instance Attribute Details

#allow_concurrentObject (readonly)

Returns the value of attribute allow_concurrent.



6
7
8
# File 'lib/ey_backup/engine.rb', line 6

def allow_concurrent
  @allow_concurrent
end

#forceObject (readonly)

Returns the value of attribute force.



6
7
8
# File 'lib/ey_backup/engine.rb', line 6

def force
  @force
end

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/ey_backup/engine.rb', line 6

def host
  @host
end

#key_idObject (readonly)

Returns the value of attribute key_id.



6
7
8
# File 'lib/ey_backup/engine.rb', line 6

def key_id
  @key_id
end

#log_coordinatesObject (readonly)

Returns the value of attribute log_coordinates.



6
7
8
# File 'lib/ey_backup/engine.rb', line 6

def log_coordinates
  @log_coordinates
end

#passwordObject (readonly)

Returns the value of attribute password.



6
7
8
# File 'lib/ey_backup/engine.rb', line 6

def password
  @password
end

#skip_analyzeObject (readonly)

Returns the value of attribute skip_analyze.



6
7
8
# File 'lib/ey_backup/engine.rb', line 6

def skip_analyze
  @skip_analyze
end

#usernameObject (readonly)

Returns the value of attribute username.



6
7
8
# File 'lib/ey_backup/engine.rb', line 6

def username
  @username
end

Class Method Details

.descendantsObject



16
17
18
# File 'lib/ey_backup/engine.rb', line 16

def self.descendants
  @descendants ||= []
end

.inherited(descendant) ⇒ Object



20
21
22
# File 'lib/ey_backup/engine.rb', line 20

def self.inherited(descendant)
  descendants << descendant
end

.labelObject



8
9
10
# File 'lib/ey_backup/engine.rb', line 8

def self.label
  @label
end

.lookup(label) ⇒ Object



24
25
26
27
# File 'lib/ey_backup/engine.rb', line 24

def self.lookup(label)
  descendants.detect {|d| d.label == label } ||
    EY::Backup.logger.fatal("Unknown database engine: #{label}")
end

.register(label) ⇒ Object



12
13
14
# File 'lib/ey_backup/engine.rb', line 12

def self.register(label)
  @label = label
end

Instance Method Details

#backup_running?Boolean

Returns:

  • (Boolean)


41
42
43
44
# File 'lib/ey_backup/engine.rb', line 41

def backup_running?
  verbose %x{ps aux | grep [e]ybackup | grep rubygems}
  %x{ps -ef | grep [e]ybackup | grep rubygems | wc -l}.to_i > 1
end

#block_concurrent(db = nil) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/ey_backup/engine.rb', line 33

def block_concurrent(db = nil)
  if backup_running?
    message = "Unable to backup #{db}: already a backup in progress. Use --allow_concurrent to enable concurrent backup runs."
    error(message, db) unless File.exists?('/etc/engineyard/skip_concurrent_alerts')  # this skips the dashboard alert
    abort message
  end
end

#gpg?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/ey_backup/engine.rb', line 46

def gpg?
  !key_id.nil? && key_id != ""
end