Module: LiquidBackup::Job::Database

Included in:
LiquidBackup::Job
Defined in:
lib/liquid_backup/job/modules/database_module.rb

Defined Under Namespace

Modules: StepCallbacks

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(parent) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/liquid_backup/job/modules/database_module.rb', line 4

def Database.included(parent)
  parent.class_eval <<-CALLBACK
    include Database::StepCallbacks
    set_callback :upload, :before do |object|
      compress_database
    end
    
    set_callback :backup, :before do |object|
      FileUtils.mkdir_p File.join(current_backup_path,'databases')
    end
    
    set_callback :upload, :after do 
      FileUtils.rm_rf(File.join(current_backup_path,'databases'))
    end
  CALLBACK
end

Instance Method Details

#database(name, options = {}) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/liquid_backup/job/modules/database_module.rb', line 31

def database(name, options = {})
  @_fire_database_callbacks = true
  
  destination    = File.join(current_backup_path,'databases', name + '_' + Date.today.strftime("%Y%m%d%H%M%S") + '.sql')
  
  `/usr/local/pgsql/bin/pg_dump -U postgres #{name} > #{destination}`
end