Class: LiquidBackup::Job

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Callbacks, Database, Folder
Defined in:
lib/liquid_backup/job.rb,
lib/liquid_backup/job/modules/folder_module.rb,
lib/liquid_backup/job/modules/database_module.rb

Defined Under Namespace

Modules: Database, Folder

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Database

#database, included

Methods included from Folder

#folder, included

Constructor Details

#initialize(script_path) ⇒ Job

Returns a new instance of Job.



21
22
23
24
25
26
27
28
# File 'lib/liquid_backup/job.rb', line 21

def initialize(script_path)
  @script_path            = script_path
  @application_directory  = script_path.gsub(/\/current\/config\/(.*).rb/,'')
  @backups_path           = File.join(application_directory,'backups')
  @current_backup_path    = File.join(backups_path,'current')
  @previous_backups_path  = File.join(backups_path,'previous')
  @notifiers              = {}
end

Instance Attribute Details

#application_directoryObject

Returns the value of attribute application_directory.



9
10
11
# File 'lib/liquid_backup/job.rb', line 9

def application_directory
  @application_directory
end

#backups_pathObject

Returns the value of attribute backups_path.



10
11
12
# File 'lib/liquid_backup/job.rb', line 10

def backups_path
  @backups_path
end

#current_backup_pathObject

Returns the value of attribute current_backup_path.



11
12
13
# File 'lib/liquid_backup/job.rb', line 11

def current_backup_path
  @current_backup_path
end

#destination_handlerObject

Returns the value of attribute destination_handler.



14
15
16
# File 'lib/liquid_backup/job.rb', line 14

def destination_handler
  @destination_handler
end

#destination_locationObject

Returns the value of attribute destination_location.



15
16
17
# File 'lib/liquid_backup/job.rb', line 15

def destination_location
  @destination_location
end

#notifiersObject

Returns the value of attribute notifiers.



17
18
19
# File 'lib/liquid_backup/job.rb', line 17

def notifiers
  @notifiers
end

#previous_backups_pathObject

Returns the value of attribute previous_backups_path.



12
13
14
# File 'lib/liquid_backup/job.rb', line 12

def previous_backups_path
  @previous_backups_path
end

#script_pathObject

Returns the value of attribute script_path.



8
9
10
# File 'lib/liquid_backup/job.rb', line 8

def script_path
  @script_path
end

Instance Method Details

#application_nameObject



58
59
60
# File 'lib/liquid_backup/job.rb', line 58

def application_name
  application_directory.split("/")[-2]
end

#backupObject



39
40
41
42
43
44
45
46
47
# File 'lib/liquid_backup/job.rb', line 39

def backup
  run_callbacks :backup do
    yield
  end
  
  run_callbacks :upload do
    upload
  end
end

#backup_sizeObject



54
55
56
# File 'lib/liquid_backup/job.rb', line 54

def backup_size
  `du -sh #{current_backup_path}`.split("\t")[0]
end

#performObject



35
36
37
# File 'lib/liquid_backup/job.rb', line 35

def perform
  eval(File.read(script_path), binding)
end